#include <bits/stdc++.h>
using namespace std;
map<pair<int, int>, bool> M;
vector<pair<int, int> > R;
vector<int> V[1200000];
vector<int> V_tmp1, V_tmp2;
vector<int>::iterator it1, it2;
int dx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int ex[] = {-2, -2, -2, -2, -2, -1, -1, 0, 0, 1, 1, 2, 2, 2, 2, 2},
    ey[] = {-2, -1, 0, 1, 2, -2, 2, -2, 2, -2, 2, -2, -1, 0, 1, 2};
int f[1200000];
char c[1200][1200];
bool b1[1200000], b2[1200000];
int p[20], q[20];
int h, i, j, k, l, m, n, o, u, v, x, y, ux, uy, vx, vy;
bool b;
inline int getfather(int x) {
  if (f[x] == x)
    return x;
  else
    return f[x] = getfather(f[x]);
}
inline int getfather_(int x) {
  if (f[x] == x)
    return x;
  else
    return getfather_(f[x]);
}
inline int id(int x, int y) {
  if (c[x][y] == '.') return -1;
  if ((x <= 0) || (y > m)) return getfather(0);
  if ((x > n) || (y <= 0)) return getfather(n * m + 1);
  if ((x > 0) && (x <= n) && (y > 0) && (y <= m))
    return getfather((x - 1) * m + y);
}
inline int id_(int x, int y) {
  if (c[x][y] == '.') return -1;
  if ((x <= 0) || (y > m)) return getfather_(0);
  if ((x > n) || (y <= 0)) return getfather_(n * m + 1);
  if ((x > 0) && (x <= n) && (y > 0) && (y <= m))
    return getfather_((x - 1) * m + y);
}
inline void dfs1(int x) {
  b1[x] = true;
  V_tmp1.push_back(x);
  vector<int>::iterator it1;
  for (it1 = V[x].begin(); it1 != V[x].end(); it1++)
    if (!b1[*it1]) dfs1(*it1);
  return;
}
inline void dfs2(int x) {
  b2[x] = true;
  V_tmp2.push_back(x);
  vector<int>::iterator it2;
  for (it2 = V[x].begin(); it2 != V[x].end(); it2++)
    if (!b2[*it2]) dfs2(*it2);
  return;
}
int main() {
  scanf("%d%d%d", &n, &m, &o);
  for (i = 1; i <= n; i++) scanf("%s", c[i] + 1);
  for (i = 0; i <= n * m + 1; i++) f[i] = i;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (c[i][j] == '#')
        for (k = 0; k < 8; k++) {
          x = i + dx[k], y = j + dy[k];
          if (id(x, y) != -1) f[id(i, j)] = id(x, y);
        }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (((i != 1) || (j != 1)) && ((i != n) || (j != m)) && (c[i][j] == '.'))
        for (k = 0; k < 8; k++) {
          ux = i + dx[k], uy = j + dy[k];
          if (id(ux, uy) != -1)
            for (l = 0; l < 8; l++) {
              vx = i + dx[l], vy = j + dy[l];
              if (id(vx, vy) != -1) {
                if (id(ux, uy) != id(vx, vy))
                  M[make_pair(id(ux, uy), id(vx, vy))] = true;
              }
            }
        }
  for (i = 0; i <= n * m + 1; i++) f[i] = getfather(i);
  u = f[0], v = f[n * m + 1];
  for (h = 1; h <= o; h++) {
    scanf("%d", &l);
    for (i = 1; i <= l; i++) scanf("%d%d", &p[i], &q[i]), c[p[i]][q[i]] = '#';
    for (i = 1; i <= l; i++)
      for (j = 0; j < 8; j++) {
        x = p[i] + dx[j], y = q[i] + dy[j];
        if (id_(x, y) != -1) {
          V[id_(p[i], q[i])].push_back(id_(x, y));
          V[id_(x, y)].push_back(id_(p[i], q[i]));
        }
      }
    for (i = 1; i <= l; i++)
      for (j = 0; j < 8; j++) {
        x = p[i] + dx[j], y = q[i] + dy[j];
        if (id_(x, y) != -1) {
          R.push_back(make_pair(id_(p[i], q[i]), f[id_(p[i], q[i])]));
          f[id_(p[i], q[i])] = id_(x, y);
        }
      }
    dfs1(u);
    dfs2(v);
    b = false;
    for (it1 = V_tmp1.begin(); it1 != V_tmp1.end(); it1++)
      for (it2 = V_tmp2.begin(); it2 != V_tmp2.end(); it2++)
        if (M[make_pair(*it1, *it2)]) b = true;
    for (i = 1; i <= l; i++)
      if (id_(p[i], q[i]) == getfather_(0))
        for (j = 0; j < 16; j++) {
          x = p[i] + ex[j], y = q[i] + ey[j];
          if (id_(x, y) == getfather_(n * m + 1)) b = true;
        }
    for (i = 1; i <= l; i++)
      if (id_(p[i], q[i]) == getfather_(n * m + 1))
        for (j = 0; j < 16; j++) {
          x = p[i] + ex[j], y = q[i] + ey[j];
          if (id_(x, y) == getfather_(0)) b = true;
        }
    if (b)
      puts("NO");
    else
      puts("YES");
    fflush(stdout);
    for (it1 = V_tmp1.begin(); it1 != V_tmp1.end(); it1++) b1[*it1] = false;
    for (it2 = V_tmp2.begin(); it2 != V_tmp2.end(); it2++) b2[*it2] = false;
    V_tmp1.clear();
    V_tmp2.clear();
    for (i = R.size() - 1; i >= 0; i--) f[R[i].first] = R[i].second;
    R.clear();
    for (i = 1; i <= l; i++)
      for (j = 0; j < 8; j++) {
        x = p[i] + dx[j], y = q[i] + dy[j];
        if (id_(x, y) != -1) V[id_(x, y)].clear();
      }
    for (i = 1; i <= l; i++) V[id_(p[i], q[i])].clear();
    for (i = 1; i <= l; i++) c[p[i]][q[i]] = '.';
  }
  return 0;
}
