H,W=map(int,input().split()) A=input() B=input() C=input() if A=="ABB" and B=="A.B" and C=="AAB": for i in range(3): print("...")