while 1: t=input() s=raw_input() t=input() c=abs(t) print c*s[::t/c]