Codeforces #36 B Fractal
input = open("input.txt","r") output = open("output.txt","w") n,k = map(int,input.readline().split()) S = list(input) for y in range(n**k): s = "" for x in range(n**k): c = "." tx,ty = x,y for i in range(k): if S[ty%n][tx%n]=="*": c = "*" tx /= n; ty /= n s += c output.write(s+"\n")