import sys input = sys.stdin.readline H, W = map(int, input().split()) S = [list(input()[:-1]) for _ in range(H)] for i in range(H): for j in range(W): if (i+j)%2==1: if S[i][j]=='.': S[i][j] = '#' else: S[i][j] = '.' M = int(input()) hs, ws = set(), set() for _ in range(M): t, n = map(int, input().split()) if t==1: hs.add(n-1) else: ws.add(n-1) for i in range(H-1): for j in range(W): if S[i][0]!=S[i+1][0] and S[i][j]==S[i+1][j]: exit(print('No')) if S[i][0]==S[i+1][0] and S[i][j]!=S[i+1][j]: exit(print('No')) if S[i][0]!=S[i+1][0] and i not in hs: exit(print('No')) for i in range(W-1): for j in range(H): if S[0][i]!=S[0][i+1] and S[j][i]==S[j][i+1]: exit(print('No')) if S[0][i]==S[0][i+1] and S[j][i]!=S[j][i+1]: exit(print('No')) if S[0][i]!=S[0][i+1] and i not in ws: exit(print('No')) print('Yes')