import sys # sys.setrecursionlimit(1000006) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = -1-(-1 << 31) # inf = -1-(-1 << 62) # md = 10**9+7 md = 998244353 def ok(): fr = [0]*rn fc = [0]*cn fr[0] = f for q, j in enumerate(col): fc[q] = ss[0][j-1] ^ (j-1) & 1 ^ f ^ v for p, i in enumerate(row): if p == 0: continue fr[p] = ss[i-1][0] ^ (i-1) & 1 ^ fc[0] ^ v tt = [[0]*(w+1) for _ in range(h+1)] l = 0 for p, r in enumerate(row): if fr[p]: tt[l][0] ^= 1 tt[r][0] ^= 1 l = r l = 0 for p, r in enumerate(col): if fc[p]: tt[0][l] ^= 1 tt[0][r] ^= 1 l = r for i in range(h): for j in range(w): tt[i][j+1] ^= tt[i][j] for i in range(h): for j in range(w): tt[i+1][j] ^= tt[i][j] # pDB(fr, fc) # p2D(tt) for i in range(h): for j in range(w): if i & 1 ^ j & 1 ^ ss[i][j] ^ tt[i][j] ^ v: return False return True h, w = LI() ss = [[c == "#" for c in SI()] for _ in range(h)] row = [] col = [] for _ in range(II()): t, n = LI() if t == 1: row.append(n) else: col.append(n) if not row: row.append(h) if not col: col.append(w) row.sort() col.sort() rn = len(row) cn = len(col) for f in range(2): for v in range(2): if ok(): print("Yes") exit() print("No")