def get_basis(a): basis = [] for e in a: for b in basis: if e > e^b: e ^= b if e: basis.append(e) return basis def normalize(v,basis): for b in basis: if v > v^b: v ^= b return v import sys n,m = map(int,input().split()) mat = sys.stdin.read().translate(str.maketrans('.#','01','\n')) #生成系 p = [0]*n q = [0]*n r = [0]*2*n s = [0]*2*n for i in range(n): for j in range(n): v = 1<<(n*i+j) p[i] ^= v q[j] ^= v r[i+j] ^= v s[i-j+n] ^= v basis = get_basis(p+q+r+s) res = [normalize(int(mat[T*n*n:(T+1)*n*n],2),basis) for T in range(m)] for i in range(m-1): print("".join("01"[res[i]==res[j]] for j in range(i+1,m))) if n==5: print(1)