H,W = map(int, input().split()) MAP = [] for _ in range(H): MAP.append(list(input())) M = int(input()) TN = [list(map(int, input().split())) for _ in range(M)] if not(2<=H<=200 and 2<=W<=200 and 0<=M<=23): exit() if len(MAP)!=H: exit() for m in MAP: if len(m)==W and m.count('#')+m.count('.')==W: continue exit() S = set() for t,n in TN: S.add((t,n)) if t==1: if 1<=n<=H: continue elif t==2: if 1<=n<=W: continue exit() if len(S)!=M or len(TN)!=M: exit() R = [0] C = [0] for t,n in TN: if t==1 and n!=H: R.append(n) if t==2 and n!=W: C.append(n) R.sort() C.sort() RS = set(R) CS = set(C) for i in range(H): for j in range(W): if (i+j)%2==1: if MAP[i][j]=='.': MAP[i][j]='#' else: MAP[i][j]='.' for i in range(H): for j in range(W-1): if MAP[i][j]!=MAP[i][j+1] and not j+1 in CS: print('No') exit() for i in range(H-1): for j in range(W): if MAP[i][j]!=MAP[i+1][j] and not i+1 in RS: print('No') exit() MAP2 = [] for r in R: L = [] for c in C: L.append(MAP[r][c]) MAP2.append(L) H2 = len(MAP2) W2 = len(MAP2[0]) for i in range(H2): if MAP2[i][0]=='#': for j in range(W2): if MAP2[i][j]=='.': MAP2[i][j]='#' else: MAP2[i][j]='.' for i in range(W2): if MAP2[0][i]=='#': for j in range(H2): if MAP2[j][i]=='.': MAP2[j][i]='#' else: MAP2[j][i]='.' for i in range(H2): for j in range(W2): if MAP2[i][j]!=MAP2[0][0]: print('No') exit() print('Yes')