I=input def J(): return map(int,I().split()) N,K=J() M=N*2 R=range(M) b=0 for i in R: for c in I():b+=c=="#" D,E=[],[] for i in R: C=list(J()) for i in R: D.append(C[i]) if i