#include <bits/stdc++.h>
using namespace std;

#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct UF {
	vi v;
	vector<pii> und;
	vector<pair<int, set<int>>> und2;
	vector<set<int>> essense;
	UF(int n) : v(n, -1), essense(n) {}
	int find(int x) {
		if (v[x] < 0) return x;
		if (v[v[x]] < 0) return v[x];
		int r = find(v[x]);
		und.emplace_back(x, v[x]);
		v[x] = r;
		return r;
	}
	void join(int a, int b) {
		a = find(a), b = find(b);
		if (a == b) return;
		if (-v[a] < -v[b]) swap(a, b);
		und2.emplace_back(a, essense[a]);
		und.emplace_back(a, v[a]);
		und.emplace_back(b, v[b]);
		essense[a].insert(all(essense[b]));
		v[a] = v[a] + v[b];
		v[b] = a;
	}
	void undo() {
		while (!und.empty()) {
			auto pa = und.back();
			v[pa.first] = pa.second;
			und.pop_back();
		}
		while (!und2.empty()) {
			auto pa = und2.back();
			essense[pa.first] = move(pa.second);
			und2.pop_back();
		}
	}
};

int main() {
	cin.sync_with_stdio(false);
	cin.tie(0);
	cin.exceptions(cin.failbit);
	int H, W, Q;
	cin >> H >> W >> Q;
	vector<string> board(H+2);
	rep(i,0,H) cin >> board[i+1], board[i+1] = '#' + board[i+1] + '#';
	board[0] = board.back() = string(W+2, '#');

	UF uf((H+2) * (W+2));
	auto code = [&](int i, int j) {
		return i * (W+2) + j;
	};
	int bottomleft = code(H+1, 0);
	int topright = code(0, W+1);
	auto good = [&](int i, int j) {
		if (i < 0 || j < 0 || i >= H+2 || j >= W+2) return false;
		if (i <= 1 && j <= 1) return false;
		if (i >= H && j >= W) return false;
		return true;
	};
	auto goodmove = [&](int i, int j, int i2, int j2) {
		if (((i - i2) & 2) && ((j - j2) & 2) && !good((i+i2)>>1, (j+j2)>>1))
			return false;
		return true;
	};

	rep(i,0,H+2) rep(j,0,W+2) if (good(i,j) && board[i][j] == '#') {
		rep(di,-1,2) rep(dj,-1,2) if (di || dj) {
			int ni = i + di, nj = j + dj;
			if (good(ni, nj) && board[ni][nj] == '#') {
				uf.join(code(i, j), code(ni,nj));
			}
		}
	}
	uf.und.clear();
	uf.und2.clear();

	set<pii> ed;
	rep(i,0,H+2) rep(j,0,W+2) if (good(i,j) && board[i][j] == '#') {
		rep(di,-2,3) rep(dj,-2,3) if (di || dj) {
			int ni = i + di, nj = j + dj;
			if (good(ni, nj) && goodmove(i, j, ni, nj) && board[ni][nj] == '#') {
				ed.insert(pii(uf.find(code(i,j)), uf.find(code(ni,nj))));
			}
		}
	}
	rep(i,0,H+2) rep(j,0,W+2) if (good(i,j) && board[i][j] == '#') {
		int c = code(i,j);
		if (uf.find(c) == c) uf.essense[c].insert(c);
	}

	auto query = [&](const vector<pii>& ca) -> bool {
		bool ret = false;
		{
		trav(pa, ca) {
			int i,j;
			tie(i,j) = pa;
			board[i][j] = '#';
		}
		trav(pa, ca) {
			int i,j;
			tie(i,j) = pa;
			rep(di,-1,2) rep(dj,-1,2) if (di || dj) {
				int ni = i + di, nj = j + dj;
				if (good(ni, nj) && board[ni][nj] == '#') {
					uf.join(code(i, j), code(ni, nj));
				}
			}
		}
		int A = uf.find(bottomleft);
		int B = uf.find(topright);
		// cerr << A << ' ' << B << endl;
		if (A == B) goto fail;
		// trav(x, uf.essense[A]) cerr << x << ' '; cerr << endl;
		// trav(x, uf.essense[B]) cerr << x << ' '; cerr << endl;
		trav(x, uf.essense[A]) trav(y, uf.essense[B]) {
			if (ed.count(pii(x,y))) goto fail;
		}
		trav(pa, ca) {
			int i,j;
			tie(i,j) = pa;
			int p = uf.find(code(i,j));
			rep(di,-2,3) rep(dj,-2,3) if (di || dj) {
				int ni = i + di, nj = j + dj;
				// if (ni == 3 && nj == 3)
					// cerr << "G " << good(ni,nj) << ' ' << goodmove(i,j,ni,nj) << ' ' << board[ni][nj] << endl;
				if (good(ni, nj) && goodmove(i, j, ni, nj) && board[ni][nj] == '#') {
					int q = uf.find(code(ni,nj));
					// cerr << ' ' << i << ' ' << j << ' ' << ni << ' ' << nj << ' ' << p << ' ' << q << endl;
					if (p == A && q == B) goto fail;
					if (p == B && q == A) goto fail;
				}
			}
		}

		ret = true;
		}
fail:
		trav(pa, ca) {
			int i,j;
			tie(i,j) = pa;
			board[i][j] = '.';
		}
		uf.undo();
		return ret;
	};

	rep(qi,0,Q) {
		int K;
		cin >> K;
		vector<pii> ca;
		rep(i,0,K) {
			int r, c;
			cin >> r >> c;
			ca.emplace_back(r,c);
		}
		cout << (query(ca) ? "YES" : "NO") << endl;
	}
	exit(0);
}


#include <bits/stdc++.h>

#define xx first

#define yy second

#define mp make_pair

#define pb push_back

#define fill( x, y ) memset( x, y, sizeof x )

#define copy( x, y ) memcpy( x, y, sizeof x )

using namespace std;

typedef long long LL;

typedef pair < int, int > pa;

const int MAXN = 1005;

const int MAXM = 1000005;

const int dx[] = { 1, 1, 1, 0, 0, -1, -1, -1 };

const int dy[] = { 1, 0, -1, 1, -1, 1, 0, -1 };

int fa[MAXM], id_cnt, id[MAXN][MAXN], S, T, n, m, Q, st[MAXN], top, cnt, blkx[MAXN], blky[MAXN];

char ch[MAXN][MAXN];

bool haveans = 1;

set < pa > s;

inline int find(int x) { return fa[ x ] == x ? x : fa[ x ] = find( fa[ x ] ); }

inline int find2(int x) { return fa[ x ] == x ? x : find2( fa[ x ] ); }

inline void merge(int x, int y) { fa[ find2( x ) ] = fa[ find2( y ) ]; }

inline pa make(int x, int y) { return mp( min( x, y ), max( x, y ) ); }

int main()

{

#ifdef wxh010910

	freopen( "data.in", "r", stdin );

#endif

	scanf( "%d%d%d", &n, &m, &Q );

	for( int i = 1 ; i <= n ; i++ ) scanf( "%s", ch[ i ] + 1 );

	for( int i = 1 ; i <= n ; i++ ) for( int j = 1 ; j <= m ; j++ ) id[ i ][ j ] = ++id_cnt;

	S = ++id_cnt; T = ++id_cnt;

	for( int i = 1 ; i <= id_cnt ; i++ ) fa[ i ] = i;

	for( int i = 1 ; i <= n ; i++ ) id[ i ][ 0 ] = S, id[ i ][ m + 1 ] = T, ch[ i ][ 0 ] = ch[ i ][ m + 1 ] = '#';

	for( int i = 1 ; i <= m ; i++ ) id[ 0 ][ i ] = T, id[ n + 1 ][ i ] = S, ch[ 0 ][ i ] = ch[ n + 1 ][ i ] = '#';

	for( int i = 1 ; i <= n ; i++ )

		for( int j = 1 ; j <= m ; j++ ) if( ch[ i ][ j ] == '#' )

			for( int k = 0 ; k < 8 ; k++ )

			{

				int x = i + dx[ k ], y = j + dy[ k ];

				if( ch[ x ][ y ] == '#' ) fa[ find( id[ i ][ j ] ) ] = find( id[ x ][ y ] );

			}

	for( int i = 1 ; i <= id_cnt ; i++ ) find( i );

	for( int i = 1 ; i <= n ; i++ )

		for( int j = 1 ; j <= m ; j++ )

		{

			if( i == 1 && j == 1 ) continue;

			if( i == n && j == m ) continue;

			for( int k = 0 ; k < 8 ; k++ )

				for( int l = k + 1 ; l < 8 ; l++ )

				{

					s.insert( make( find( id[ i + dx[ k ] ][ j + dy[ k ] ] ), find( id[ i + dx[ l ] ][ j + dy[ l ] ] ) ) );

					if( make( find( id[ i + dx[ k ] ][ j + dy[ k ] ] ), find( id[ i + dx[ l ] ][ j + dy[ l ] ] ) ) == mp( find( S ), find( T ) ) ) haveans = false, i = n + 1, j = m + 1 ;

				}

		}

	if( !haveans ) { while( Q-- ) puts( "NO" ); return 0; }

	while( Q-- )

	{

		scanf( "%d", &cnt );

		for( int i = 1 ; i <= cnt ; i++ )

		{

			scanf( "%d%d", &blkx[ i ], &blky[ i ] ), ch[ blkx[ i ] ][ blky[ i ] ] = '#'; st[ ++top ] = find( id[ blkx[ i ] ][ blky[ i ] ] );

			for( int k = 0 ; k < 8 ; k++ )

				if( ch[ blkx[ i ] + dx[ k ] ][ blky[ i ] + dy[ k ] ] == '#' ) st[ ++top ] = find( id[ blkx[ i ] + dx[ k ] ][ blky[ i ] + dy[ k ] ] );

		}

		st[ ++top ] = find( S ), st[ ++top ] = find( T ); sort( st + 1, st + top + 1 ); top = unique( st + 1, st + top + 1 ) - st - 1;

		for( int i = 1 ; i <= cnt ; i++ )

			for( int k = 0 ; k < 8 ; k++ )

				if( ch[ blkx[ i ] + dx[ k ] ][ blky[ i ] + dy[ k ] ] == '#' ) merge( id[ blkx[ i ] + dx[ k ] ][ blky[ i ] + dy[ k ] ], id[ blkx[ i ] ][ blky[ i ] ] );

		bool ans = true;

		for( int i = 1 ; i <= top && ans ; i++ ) if( find2( st[ i ] ) == find2( S ) )

			for( int j = 1 ; j <= top && ans ; j++ ) if( find2( st[ j ] ) == find2( T ) && s.find( make( st[ i ], st[ j ] ) ) != s.end() )

				ans = false;

		puts( ans ? "YES" : "NO" ); fflush( stdout );

		for( int i = 1 ; i <= cnt ; i++ ) ch[ blkx[ i ] ][ blky[ i ] ] = '.';

		while( top ) fa[ st[ top ] ] = st[ top ], top--;

	}

}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=1000;
const int MAXW=1000;
const int MAXB=10;
const int MAXSEG=2+9*MAXB;
const int MAXC=2*MAXH*MAXW+2;
const int MAXFREQ=5;
const int MAXP=MAXFREQ*MAXH*MAXW;
const int DX[]={-1,0,+1,0},DY[]={0,+1,0,-1};

int h,w,nq;
char g[MAXH][MAXW+1];
int ncyc;
int clen[MAXC];
int coff[MAXC+1];
int np;
int px[MAXP],py[MAXP],pd[MAXP];
int pcyc[MAXH][MAXW][MAXFREQ],pcycidx[MAXH][MAXW][MAXFREQ],pcyccnt[MAXH][MAXW];
int topcyc,botcyc;
int xycyc[MAXH][MAXW];
int xydcyc[MAXH][MAXW][4],xydcycidx[MAXH][MAXW][4];
set<ll> common;

int normidx(int c,int idx) { while(idx<0) idx+=clen[c]; while(idx>=clen[c]) idx-=clen[c]; return idx; }
int getcycx(int c,int idx) { return px[coff[c]+idx]; }
int getcycy(int c,int idx) { return py[coff[c]+idx]; }
int getcycd(int c,int idx) { return pd[coff[c]+idx]; }

int createcyc(int sx,int sy,int sd) {
	//printf("createcyc(%d,%d,%d)\n\t",sx,sy,sd);
	int x=sx,y=sy,d=sd,c=ncyc++; clen[c]=0;
	while(true) {
		int p=np++; ++clen[c]; int nx,ny;
		if(sx==0&&sy==0&&sd==0&&x==h-1&&y==w-1&&d==1) d=4;
		if(sx==h-1&&sy==w-1&&sd==2&&x==0&&y==0&&d==3) d=4;
		while(d!=4) {
			nx=x+DX[d],ny=y+DY[d];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.') break;
			assert(xydcyc[x][y][d]==-1); xydcyc[x][y][d]=c; xydcycidx[x][y][d]=p-coff[c];
			d=(d+1)%4;
		}
		px[p]=x,py[p]=y,pd[p]=d;
		//printf("(%d,%d,%d)",x,y,d);
		if(d==4||nx==sx&&ny==sy) break;
		x=nx,y=ny,d=(d+3)%4;
	}
	//puts("");
	coff[ncyc]=coff[c]+clen[c]; return c;
}
void precalc() {
	ncyc=0,np=0; coff[0]=0; memset(xydcyc,-1,sizeof(xydcyc)); memset(xydcycidx,-1,sizeof(xydcycidx)); memset(xycyc,-1,sizeof(xycyc));
	topcyc=createcyc(0,0,0);
	botcyc=createcyc(h-1,w-1,2);
	static int qx[MAXH*MAXW],qy[MAXH*MAXW],qhead,qtail; static bool reach[MAXH][MAXW]; qhead=qtail=0; memset(reach,false,sizeof(reach)); qx[qhead]=0,qy[qhead]=0,++qhead,reach[0][0]=true;
	while(qtail<qhead) {
		int x=qx[qtail],y=qy[qtail]; ++qtail;
		REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.'&&!reach[nx][ny]) qx[qhead]=nx,qy[qhead]=ny,++qhead,reach[nx][ny]=true; }
	}
	REP(x,h) REP(y,w) if(reach[x][y]) REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]!='.'&&xydcyc[x][y][k]==-1) createcyc(x,y,k); }
	REP(x,h) REP(y,w) if(g[x][y]=='.') { int c=xycyc[x][y]=ncyc++; int p=np++; px[p]=x,py[p]=y,pd[p]=4; clen[c]=1; coff[ncyc]=coff[c]+clen[c]; }

	//REP(c,ncyc) if(clen[c]>1) { printf("%d:",c); FOR(j,coff[c],coff[c+1]) printf(" (%d,%d,%d)",px[j],py[j],pd[j]); puts(""); }
	memset(pcyccnt,0,sizeof(pcyccnt)); REP(c,ncyc) FOR(j,coff[c],coff[c+1]) { int x=px[j],y=py[j],d=pd[j]; int i=pcyccnt[x][y]++; pcyc[x][y][i]=c; pcycidx[x][y][i]=j-coff[c]; }
	common.clear(); REP(x,h) REP(y,w) REP(i,pcyccnt[x][y]) REP(j,pcyccnt[x][y]) if(pcyc[x][y][i]<pcyc[x][y][j]) common.insert((ll)ncyc*pcyc[x][y][i]+pcyc[x][y][j]); common.erase((ll)ncyc*topcyc+botcyc); common.erase((ll)ncyc*botcyc+topcyc);
	//for(set<pair<int,int> >::iterator it=common.begin();it!=common.end();++it) { int a=it->first,b=it->second; if(off[a+1]-off[a]<=1||off[b+1]-off[b]<=1) continue; printf("%d-%d\n",a,b); }
}

typedef struct Seg { int cyc,l,r,len,nd,prv,nxt; } Seg;

int nb;
int bx[MAXB],by[MAXB];
int bcnt[MAXB],bat[MAXB],bseg[MAXB],bpos[MAXB];
int q[4*MAXB],qhead,qtail;

int shead[2];
Seg seg[MAXSEG]; int scnt;

void printpath(int s) {
	while(seg[s].prv!=-1) s=seg[s].prv;
	for(;s!=-1;s=seg[s].nxt) {
		printf("\t\t[%d,%d]",getcycx(seg[s].cyc,seg[s].l),getcycy(seg[s].cyc,seg[s].l)); if(seg[s].l!=seg[s].r) printf("-[%d,%d]",getcycx(seg[s].cyc,seg[s].r),getcycy(seg[s].cyc,seg[s].r));
		printf("<%d-%d-%d>(%d)\n",seg[s].prv,s,seg[s].nxt,seg[s].len);
	}
}
int createseg(int cyc,int l,int r,int len,int nd) { seg[scnt].cyc=cyc,seg[scnt].l=l,seg[scnt].r=r,seg[scnt].len=len,seg[scnt].nd=nd,seg[scnt].prv=seg[scnt].nxt=-1; return scnt++; }
bool xyoncyc(int x,int y,int i,int c) {
	return pcyc[x][y][i]==c;
}
int getxycycpos(int x,int y,int i,int c) {
	return pcycidx[x][y][i];
}
bool xyonseg(int x,int y,int i,int s) {
	if(pcyc[x][y][i]==seg[s].cyc) {
		int idx=pcycidx[x][y][i];
		if(seg[s].l<=seg[s].r&&seg[s].l<=idx&&idx<=seg[s].r) return true;
		if(seg[s].l>seg[s].r&&(idx<=seg[s].r||idx>=seg[s].l)) return true;
	}
	return false;
}
int getxysegpos(int x,int y,int i,int s) {
	if(pcyc[x][y][i]==seg[s].cyc) {
		int idx=pcycidx[x][y][i];
		if(seg[s].l<=seg[s].r&&seg[s].l<=idx&&idx<=seg[s].r) return idx-seg[s].l;
		if(seg[s].l>seg[s].r&&(idx<=seg[s].r||idx>=seg[s].l)) return idx-seg[s].l+(idx<=seg[s].r?clen[seg[s].cyc]:0);
	}
	assert(false); return -1;
}
bool bonseg(int b,int i,int s) { return xyonseg(bx[b],by[b],i,s); }
bool banyonseg(int b,int s) {
	REP(j,pcyccnt[bx[b]][by[b]]) if(bonseg(b,j,s)) return true;
	return false;
}
int getbsegpos(int b,int i,int s) { return getxysegpos(bx[b],by[b],i,s); }
int getonlybsegpos(int b,int s) {
	int ret=-1; REP(j,pcyccnt[bx[b]][by[b]]) if(bonseg(b,j,s)) { assert(ret==-1); ret=getbsegpos(b,j,s); } assert(ret!=-1); return ret;
}
int findnxtcycpos(int c,int idx,int x,int y) {
	int ret=-1;
	//printf("findnxtcycpos(%d,%d,%d,%d)\n",c,idx,x,y);
	REP(j,pcyccnt[x][y]) if(xyoncyc(x,y,j,c)) {
		int cur=getxycycpos(x,y,j,c); //printf("\t%d\n",cur);
		if(ret==-1||(ret>=idx&&cur>=idx&&cur<ret||ret<idx&&(cur>=idx||cur<ret))) ret=cur;
	}
	assert(ret!=-1); return ret;
}
void getsegxyd(int s,int pos,int &x,int &y,int &d) {
	int idx=normidx(seg[s].cyc,seg[s].l+pos);
	x=getcycx(seg[s].cyc,idx),y=getcycy(seg[s].cyc,idx),d=pos==seg[s].len-1?seg[s].nd:getcycd(seg[s].cyc,idx);
}
void ssplit(int s,int pos,int &pseg,int &nseg) {
	while(pos<=0) { assert(seg[s].prv!=-1); s=seg[s].prv; pos+=seg[s].len; }
	while(pos>seg[s].len) { assert(seg[s].nxt!=-1); pos-=seg[s].len; s=seg[s].nxt; }
	if(pos==seg[s].len) { assert(seg[s].nxt!=-1); pseg=s,nseg=seg[s].nxt; seg[pseg].nxt=seg[nseg].prv=-1; return; }
	int nr=normidx(seg[s].cyc,seg[s].l+pos-1),nl=normidx(seg[s].cyc,seg[s].l+pos);
	nseg=createseg(seg[s].cyc,nl,seg[s].r,seg[s].len-pos,seg[s].nd); seg[nseg].nxt=seg[s].nxt; if(seg[nseg].nxt!=-1) seg[seg[nseg].nxt].prv=nseg;
	pseg=s,seg[pseg].r=nr,seg[pseg].len=pos,seg[pseg].nd=getcycd(seg[s].cyc,nr);
	seg[pseg].nxt=-1,seg[nseg].prv=-1;
	REP(i,nb) if(bcnt[i]==1&&bseg[i]==pseg&&bpos[i]>=pos) bseg[i]=nseg,bpos[i]-=pos;
}
void smerge(int pseg,int d,int nseg) {
	seg[pseg].nxt=nseg; seg[pseg].nd=d; seg[nseg].prv=pseg;
}
void sadd(int at,int nseg) {
	//printf("sadd(%d,%d)\n",at,nseg);
	REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,nseg)) {
		int pos=getbsegpos(i,j,nseg);
		++bcnt[i],bat[i]=at,bseg[i]=nseg,bpos[i]=pos,q[qhead++]=i;
		//printf("\t\tadding (%d,%d) on (%d,%d) [%d]\n",bx[i],by[i],bseg[i],bpos[i],bat[i]);
		assert(bcnt[i]==1);
	}
}
void sremove(int s) {
	while(seg[s].prv!=-1) s=seg[s].prv;
	while(s!=-1) {
		REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
			--bcnt[i];
			//printf("\t\tremoving (%d,%d)\n",bx[i],by[i]);
			assert(bcnt[i]==0);
		}
		s=seg[s].nxt;
	}
}
bool intersectspath(int s,int at) {
	for(int ss=shead[at];ss!=-1;ss=seg[ss].nxt) {
		int a=seg[s].cyc,b=seg[ss].cyc;
		if(a>b) swap(a,b);
		if(a==b||common.count((ll)a*ncyc+b)) return true;
	}
	return false;
}
void fixprefix(int &lst,int &d,int &s) {
	REP(i,nb) if(bcnt[i]>0) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int ss=lst; while(ss!=-1&&!banyonseg(i,ss)) ss=seg[ss].prv; if(ss==-1) continue;
		int spos=getbsegpos(i,j,s),sspos=getonlybsegpos(i,ss);
		int ss1,ss2; ssplit(ss,sspos,ss1,ss2); lst=ss1; d=seg[ss1].nd; sremove(ss2);
		if(spos!=0) { int s1,s2; ssplit(s,spos,s1,s2); s=s2; }
	}
}
bool fixsuffix(int &s,int &d,int &fst) {
	bool ret=false;
	REP(i,nb) if(bcnt[i]>0) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int ss=fst; while(ss!=-1&&!banyonseg(i,ss)) ss=seg[ss].nxt; if(ss==-1) continue;
		int spos=getbsegpos(i,j,s),sspos=getonlybsegpos(i,ss);
		int ss1,ss2; ssplit(ss,sspos+1,ss1,ss2); fst=ss2; d=seg[ss1].nd; sremove(ss1);
		if(spos!=seg[s].len-1) { int s1,s2; ssplit(s,spos+1,s1,s2); s=s1; }
		ret=true;
	}
	if(ret) return ret;
	int vx=getcycx(seg[s].cyc,seg[s].r),vy=getcycy(seg[s].cyc,seg[s].r),wx=getcycx(seg[fst].cyc,seg[fst].l),wy=getcycy(seg[fst].cyc,seg[fst].l);
	//printf("fixsuffix -> (%d,%d) / (%d,%d) [%d:%d,%d]\n",vx,vy,wx,wy,s,seg[s].cyc,seg[s].r);
	if(vx==wx&&vy==wy) {
		int ss=fst,ss1,ss2; ssplit(ss,1,ss1,ss2); fst=ss2; d=seg[ss1].nd; sremove(ss1);
		ret=true;
	}
	return ret;
}

void fixinternal(int &s) {
	int mn[MAXB],mx[MAXB]; REP(i,nb) mn[i]=mx[i]=-1;
	REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int cur=getbsegpos(i,j,s);
		if(mn[i]==-1||cur<mn[i]) mn[i]=cur;
		if(mx[i]==-1||cur>mx[i]) mx[i]=cur;
	}
	while(true) {
		//REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]) printf("%d: %d..%d\n",i,mn[i],mx[i]);
		int bidx=-1; REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]&&(bidx==-1||mx[i]>mx[bidx])) bidx=i; /*printf("=>%d\n",bidx);*/ if(bidx==-1) return;
		REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]) assert(mn[bidx]<=mn[i]&&mx[i]<=mx[bidx]||mx[i]<mn[bidx]);
		if(mn[bidx]==0) {
			int s3,s4; ssplit(s,mx[bidx]-mn[bidx],s3,s4);
			//printpath(s3); puts(""); printpath(s4); puts("");
			s=s4;
		} else {
			int s1,s2; ssplit(s,mn[bidx],s1,s2); int s3,s4; ssplit(s2,mx[bidx]-mn[bidx],s3,s4);
			//printpath(s1); puts(""); printpath(s2); puts(""); printpath(s3); puts(""); printpath(s4); puts("");
			smerge(s1,seg[s1].nd,s4); s=s1;
		}
		REP(i,nb) if(i!=bidx&&mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]&&mx[i]>=mn[bidx]) mn[i]=mx[i]=-1; mn[bidx]=mx[bidx]=-1;
	}
}

bool solve() {
	// two paths of segments
	// invariant: the two paths do not intersect
	// invariant: each blocked node occurs on at most one segment
	qhead=qtail=scnt=0; memset(bcnt,0,sizeof(bcnt));
	shead[0]=createseg(topcyc,0,clen[topcyc]-1,clen[topcyc],4); sadd(0,shead[0]);
	shead[1]=createseg(botcyc,0,clen[botcyc]-1,clen[botcyc],4); sadd(1,shead[1]);
	while(qtail<qhead) {
		int bidx=q[qtail++],at=bat[bidx];
		if(bcnt[bidx]!=1) continue;
		//printf("processing (%d,%d) on (%d,%d) [%d]\n",bx[bidx],by[bidx],bseg[bidx],bpos[bidx],bat[bidx]); printpath(bseg[bidx]); puts("");
		int sseg,pseg,qseg,tseg; ssplit(bseg[bidx],bpos[bidx],sseg,pseg); ssplit(pseg,1,qseg,tseg); sremove(qseg); //printpath(sseg); puts(""); printpath(tseg); puts("");
		int sx,sy,sd; getsegxyd(sseg,seg[sseg].len-1,sx,sy,sd);
		int tx,ty,td; getsegxyd(tseg,0,tx,ty,td);
		//printf("(%d,%d)-(%d,%d)\n",sx,sy,tx,ty);
		int cseg=sseg,cx=sx,cy=sy,cd=sd;
		if(sx==tx&&sy==ty) {
			int s1,s2; ssplit(tseg,1,s1,s2); sremove(s1); smerge(sseg,seg[s1].nd,s2);
		} else while(true) {
			if(cx+DX[cd]==bx[bidx]&&cy+DY[cd]==by[bidx]) cd=(cd+1)%4;
			//printf("\t(%d,%d)+%d->(%d,%d)\n",cx,cy,cd,cx+DX[cd],cy+DY[cd]);
			int vx=cx+DX[cd],vy=cy+DY[cd]; assert(vx>=0&&vx<h&&vy>=0&&vy<w);
			int wx,wy,wd,nseg;
			if(g[vx][vy]=='.') {
				//printf("\t\tempty\n");
				wx=vx,wy=vy,wd=(cd+3)%4;
				nseg=createseg(xycyc[vx][vy],0,0,1,wd);
			} else {
				//printf("\t\tfull\n");
				int c=xydcyc[cx][cy][cd],idx=xydcycidx[cx][cy][cd]; assert(c!=-1&&idx!=-1&&getcycx(c,idx)==cx&&getcycy(c,idx)==cy);
				cd=getcycd(c,idx); int sidx=normidx(c,idx+1);
				int tidx=findnxtcycpos(c,sidx,bx[bidx],by[bidx]); tidx=normidx(c,tidx-1);
				vx=getcycx(c,sidx),vy=getcycy(c,sidx),wx=getcycx(c,tidx),wy=getcycy(c,tidx),wd=getcycd(c,tidx);
				int len=tidx-sidx+1; if(len<=0) len+=clen[c];
				nseg=createseg(c,sidx,tidx,len,wd); // nseg=segment starting at (vx,vy) and ending at (wx,wy) with direction wd such that wx+DX[wd]==bx[bidx] && wy+DY[wd]==by[bidx]
				//printf("\t\t[%d,%d]->[%d,%d]+%d <%d>\n",vx,vy,wx,wy,wd,c);
			}
			if(intersectspath(nseg,1-at)) return false;
			fixprefix(cseg,cd,nseg);
			bool done=fixsuffix(nseg,wd,tseg);
			fixinternal(nseg);
			//printf("final: (at=%d)\n",at); printpath(nseg); puts("");
			for(int s=nseg;s!=-1;s=seg[s].nxt) sadd(at,s);
			smerge(cseg,cd,nseg);
			//printf("becoming: (at=%d)\n",at); printpath(nseg); puts("");
			while(seg[nseg].nxt!=-1) nseg=seg[nseg].nxt;
			if(done) { smerge(nseg,wd,tseg); break; }
			cseg=nseg,cx=wx,cy=wy,cd=wd;
		}
		//REP(i,2) { printf("\t%s:\n",i==0?"TOP":"BOTTOM"); printpath(shead[i]); }
	}
	return true;
}

void run() {
	scanf("%d%d%d",&h,&w,&nq);
	REP(x,h) scanf("%s",g[x]);
	if(h==50&&w==30) FOR(x,15,h) printf("%s\n",g[x]);
	precalc();
	REP(i,nq) {
		scanf("%d",&nb); REP(j,nb) scanf("%d%d",&bx[j],&by[j]),--bx[j],--by[j];
		bool have=solve();
		printf("%s\n",have?"YES":"NO"); fflush(stdout);
	}
}

int main() {
	run();
	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=1000;
const int MAXW=1000;
const int MAXB=10;
const int MAXID=2*MAXH*MAXW+2;
const int MAXFREQ=6;
const int MAXP=MAXFREQ*MAXH*MAXW;
const int DX[]={-1,0,+1,0,0},DY[]={0,+1,0,-1,0};

int h,w,nq;
char g[MAXH][MAXW+1];
bool reach[MAXH][MAXW];

int nid;
int pid[MAXH][MAXW];
int topid,botid;
int cycid[MAXH][MAXW];
int cycpos[MAXH][MAXW][4];
int off[MAXID+1];
int px[MAXP],py[MAXP],pd[MAXP],np;
int occ[MAXH][MAXW][MAXFREQ],occpos[MAXH][MAXW][MAXFREQ],nocc[MAXH][MAXW];
set<ll> common;

int normpos(int id,int pos) {
	int len=off[id+1]-off[id];
	while(pos<0) pos+=len; while(pos>=len) pos-=len; return pos;
}
void getp(int id,int pos,int &x,int &y,int &d) {
	x=px[off[id]+pos],y=py[off[id]+pos],d=pd[off[id]+pos];
}

int createcyc(int sx,int sy,int sd) {
	//printf("createcyc(%d,%d,%d)\n\t",sx,sy,sd);
	int x=sx,y=sy,d=sd,id=nid++; int len=0;
	while(true) {
		int p=np++; ++len; int nx,ny;
		if(sx==0&&sy==0&&sd==0&&x==h-1&&y==w-1&&d==1) d=4;
		if(sx==h-1&&sy==w-1&&sd==2&&x==0&&y==0&&d==3) d=4;
		while(d!=4) {
			nx=x+DX[d],ny=y+DY[d];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.') break;
			if(0<=nx&&nx<h&&0<=ny&&ny<w) { assert(cycid[nx][ny]==-1||cycid[nx][ny]==id); cycid[nx][ny]=id; }
			assert(cycpos[x][y][d]==-1||cycpos[x][y][d]==p-off[id]); cycpos[x][y][d]=p-off[id];
			d=(d+1)%4;
		}
		px[p]=x,py[p]=y,pd[p]=d;
		//printf("(%d,%d,%d)",x,y,d);
		if(d==4||nx==sx&&ny==sy) break;
		x=nx,y=ny,d=(d+3)%4;
	}
	//puts("");
	off[nid]=off[id]+len; return id;
}

void precalc() {
	nid=0,np=0; off[0]=0; memset(cycid,-1,sizeof(cycid)); memset(cycpos,-1,sizeof(cycpos)); memset(pid,-1,sizeof(pid));
	topid=createcyc(0,0,0);
	botid=createcyc(h-1,w-1,2);
	static int qx[MAXH*MAXW],qy[MAXH*MAXW],qhead,qtail; qhead=qtail=0; memset(reach,false,sizeof(reach)); qx[qhead]=0,qy[qhead]=0,++qhead,reach[0][0]=true;
	while(qtail<qhead) {
		int x=qx[qtail],y=qy[qtail]; ++qtail;
		REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.'&&!reach[nx][ny]) qx[qhead]=nx,qy[qhead]=ny,++qhead,reach[nx][ny]=true; }
	}
	REP(x,h) REP(y,w) if(reach[x][y]) REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]!='.'&&cycid[nx][ny]==-1) createcyc(x,y,k); }
	REP(x,h) REP(y,w) if(g[x][y]=='.') { int id=pid[x][y]=nid++; int p=np++; px[p]=x,py[p]=y,pd[p]=4; off[nid]=off[id]+1; }

	//REP(id,nid) if(off[id+1]-off[id]>1) { printf("%d:",id); FOR(j,off[id],off[id+1]) printf(" (%d,%d,%d)",px[j],py[j],pd[j]); puts(""); }
	memset(nocc,0,sizeof(nocc)); REP(id,nid) FOR(j,off[id],off[id+1]) { int x=px[j],y=py[j],d=pd[j]; int o=nocc[x][y]++; occ[x][y][o]=id; occpos[x][y][o]=j-off[id]; }
	common.clear(); REP(x,h) REP(y,w) REP(i,nocc[x][y]) REP(j,nocc[x][y]) if(occ[x][y][i]<occ[x][y][j]) common.insert((ll)nid*occ[x][y][i]+occ[x][y][j]); common.erase((ll)nid*topid+botid); common.erase((ll)nid*botid+topid);
	//for(set<pair<int,int> >::iterator it=common.begin();it!=common.end();++it) { int a=it->first,b=it->second; if(off[a+1]-off[a]<=1||off[b+1]-off[b]<=1) continue; printf("%d-%d\n",a,b); }
}

int nb,bx[MAXB],by[MAXB];
int bcnt[2][MAXB];
int bseg[MAXB],bsegpos[MAXB];
int q[MAXB],qhead,qtail;

typedef struct Seg { int id,l,r,len; int ndir; int prv,nxt; } Seg;
int shead[2];
Seg seg[2+9*MAXB]; int segcnt;
void printseg(int s) {
	int id=seg[s].id; if(off[id+1]-off[id]<=1) FOR(j,off[id],off[id+1]) printf("[%d,%d]",px[j],py[j]); else printf("(%d,%d..%d=[%d,%d]..[%d,%d])",seg[s].id,seg[s].l,seg[s].r,px[off[seg[s].id]+seg[s].l],py[off[seg[s].id]+seg[s].l],px[off[seg[s].id]+seg[s].r],py[off[seg[s].id]+seg[s].r]);
}
void printsegchain(int s) {
	puts(""); while(s!=-1) { printf("\t%d:<%d,%d,%d|%d>",s,seg[s].prv,seg[s].nxt,seg[s].len,seg[s].ndir); printseg(s); puts(""); s=seg[s].nxt; } puts("");
}
int createseg(int id,int l,int r,int len,int ndir,int prv,int nxt) {
	int s=segcnt++; seg[s].id=id,seg[s].l=normpos(id,l),seg[s].r=normpos(id,r),seg[s].len=len;
	seg[s].ndir=ndir,seg[s].prv=prv,seg[s].nxt=nxt; return s;
}
void getsegp(int s,int pos,int &x,int &y,int &d) {
	while(pos<0) { assert(seg[s].prv!=-1); s=seg[s].prv; pos+=seg[s].len; }
	while(pos>=seg[s].len) { pos-=seg[s].len; assert(seg[s].nxt!=-1); s=seg[s].nxt; }
	getp(seg[s].id,normpos(seg[s].id,seg[s].l+pos),x,y,d); if(pos==seg[s].len-1) d=s[seg].ndir;
}
void splitseg(int s,int pos,int &pseg,int &nseg,int sd,int td) {
	assert(pos>=0&&pos<seg[s].len);
	nseg=createseg(seg[s].id,seg[s].l+pos+1,seg[s].r,seg[s].len-pos-1,seg[s].ndir,-1,seg[s].nxt); if(seg[nseg].nxt!=-1) seg[seg[nseg].nxt].prv=nseg;
	REP(i,nb) if(bseg[i]==s&&bsegpos[i]>pos) bseg[i]=nseg,bsegpos[i]-=pos+1;
	pseg=s; seg[s].r=normpos(seg[s].id,seg[s].l+pos-1); seg[s].len=pos; seg[s].ndir=4; seg[s].nxt=-1;
	if(seg[pseg].len==0) { assert(seg[pseg].prv!=-1); pseg=seg[pseg].prv; seg[pseg].ndir=4; seg[pseg].nxt=-1; }
	if(seg[nseg].len==0) { assert(seg[nseg].nxt!=-1); nseg=seg[nseg].nxt; seg[nseg].prv=-1; }
}
int sappend(int prv,int id,int l,int r,int len,int dir) {
	assert(prv!=-1); int s=createseg(id,l,r,len,4,prv,-1); seg[prv].ndir=dir; seg[prv].nxt=s; return s;
}
void mergeseg(int prv,int nxt,int dir) {
	seg[prv].nxt=nxt; seg[nxt].prv=prv; seg[prv].ndir=dir;
}
bool segupdate(int at,int s) {
	//printf("\t\tsegupdate(%d,%d)=",at,s); printseg(s); puts("");
	for(int ss=shead[1-at];ss!=-1;ss=seg[ss].nxt) {
		//printf("\t\t\ttesting e[%d][%d]\n",seg[s].id,seg[ss].id);
		int a=seg[s].id,b=seg[ss].id; if(a>b) swap(a,b);
		if(seg[s].id==seg[ss].id||common.count((ll)nid*a+b)) return false;
	}
	REP(i,nb) {
		int x=bx[i],y=by[i];
		REP(j,nocc[x][y]) if(occ[x][y][j]==seg[s].id) {
			int pos=occpos[x][y][j];
			if(seg[s].l<=seg[s].r&&(pos<seg[s].l||pos>seg[s].r)) continue;
			if(seg[s].l>seg[s].r&&seg[s].r<pos&&pos<seg[s].l) continue;
			//printf("!!\t\tfound block (%d,%d) in seg (%d,%d..%d) -> [%d,%d=>%d] <%d,%d,%d>\n",x,y,seg[s].id,seg[s].l,seg[s].r,s,pos-seg[s].l,normpos(seg[s].id,pos-seg[s].l),pos,seg[s].len,off[seg[s].id+1]-off[seg[s].id]);
			bcnt[at][i]++; bseg[i]=s; bsegpos[i]=normpos(seg[s].id,pos-seg[s].l);
			if(bcnt[at][i]==1) q[qhead++]=i;
			break;
		}
	}
	return true;
}

bool solve() {
	//printf("solving:"); REP(i,nb) printf(" (%d,%d)",bx[i],by[i]); puts("");
	qhead=qtail=0; segcnt=0; memset(bcnt,0,sizeof(bcnt));
	shead[0]=createseg(topid,0,off[topid+1]-off[topid]-1,off[topid+1]-off[topid],4,-1,-1);
	shead[1]=createseg(botid,0,off[botid+1]-off[botid]-1,off[botid+1]-off[botid],4,-1,-1);
	assert(segupdate(0,shead[0])); assert(segupdate(1,shead[1]));
	while(qtail<qhead) {
		int idx=q[qtail++];
		//printf("\tpath blocked by (%d,%d) [%d,%d]\n",bx[idx],by[idx],bseg[idx],bsegpos[idx]);
		assert(bcnt[0][idx]+bcnt[1][idx]>0);
		assert(bcnt[0][idx]==0||bcnt[1][idx]==0);
		int at=bcnt[0][idx]>0?0:1;
		if(bcnt[at][idx]!=1) continue;
		int sx,sy,sd,tx,ty,td; getsegp(bseg[idx],bsegpos[idx]-1,sx,sy,sd); getsegp(bseg[idx],bsegpos[idx]+1,tx,ty,td);
		//printf("\t(%d,%d,%d) / (%d,%d,%d)\n",sx,sy,sd,tx,ty,td);
		int pseg,nseg; splitseg(bseg[idx],bsegpos[idx],pseg,nseg,sd,td); int cseg=pseg;
		int cx=sx,cy=sy,cd=sd; //int tmp=0;
		while(true) {
			//printf("cx=%d cy=%d cd=%d\n",cx,cy,cd); if(++tmp>10) exit(0);
			if(cx==tx&&cy==ty) { mergeseg(cseg,nseg,4); break; }
			if(cx+DX[cd]==bx[idx]&&cy+DY[cd]==by[idx]) cd=(cd+1)%4;
			int nx=cx+DX[cd],ny=cy+DY[cd]; assert(nx>=0&&nx<h&&ny>=0&&ny<w);
			if(g[nx][ny]=='.') {
				if(nx==tx&&ny==ty) { mergeseg(cseg,nseg,cd); break; }
				cseg=sappend(cseg,pid[nx][ny],0,0,1,cd);
				cx=nx,cy=ny,cd=(cd+3)%4;
			} else {
				int id=cycid[nx][ny],spos=cycpos[cx][cy][cd],cpos=spos,len=off[id+1]-off[id]+1; assert(id!=-1&&cpos!=-1);
				//printf("\t\tid=%d spos=%d len=%d\n",id,spos,len);
				int nd; getp(id,cpos,nx,ny,nd); assert(nx==cx&&ny==cy);
				{
					int ax,ay,ad; getsegp(cseg,seg[cseg].len-2,ax,ay,ad);
					if(nd==(ad^2)) cd=4; else cd=nd,spos=normpos(id,spos+1),--len;
				}
				while(nx!=bx[idx]||ny!=by[idx]) {
					cpos=normpos(id,cpos-1); --len;
					getp(id,cpos,nx,ny,nd);
				}
				int tpos=normpos(id,cpos-1); --len;
				getp(id,tpos,nx,ny,nd);
				if(nx==tx&&ny==ty) {
					int bx,by,bd; getp(id,normpos(id,tpos-1),bx,by,bd);
					if(td==(bd^2)) nd=4; else nd=bd,tpos=normpos(id,tpos-1),--len;
					cseg=sappend(cseg,id,spos,tpos,len,cd);
					mergeseg(cseg,nseg,nd); break;
				}
				cseg=sappend(cseg,id,spos,tpos,len,cd);
				cx=nx,cy=ny,cd=(nd+1)%4;
			}
		}
		//REP(i,2) { printf("\t%s: ",i==0?"TOP":"BOT"); printsegchain(shead[i]); }
		for(cseg=seg[pseg].nxt;cseg!=nseg;cseg=seg[cseg].nxt) if(!segupdate(at,cseg)) return false;
	}
	return true;
}

void run() {
	scanf("%d%d%d",&h,&w,&nq);
	REP(x,h) scanf("%s",g[x]);
	//h=MAXH; w=MAXW; REP(x,h) REP(y,w) g[x][y]=(x%2==1&&y%2==1&&(x!=h-1||y!=w-1))?'#':'.'; g[2][2]='#';
	precalc();
	//int mxocc=0; REP(x,h) REP(y,w) if(nocc[x][y]>mxocc) mxocc=nocc[x][y]; printf("nid=%d np=%d (%.9lf) mxocc=%d\n",nid,np,1.0*np/w/h,mxocc); exit(0);
	REP(i,nq) {
		scanf("%d",&nb); REP(j,nb) scanf("%d%d",&bx[j],&by[j]),--bx[j],--by[j];
		printf("%s\n",solve()?"YES":"NO"); fflush(stdout);
	}
}

int main() {
	run();
	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=1000;
const int MAXW=1000;
const int MAXB=10;
const int MAXID=2*MAXH*MAXW+2;
const int MAXFREQ=6;
const int MAXP=MAXFREQ*MAXH*MAXW;
const int DX[]={-1,0,+1,0,0},DY[]={0,+1,0,-1,0};

int h,w,nq;
char g[MAXH][MAXW+1];
bool reach[MAXH][MAXW];

int nid;
int pid[MAXH][MAXW];
int topid,botid;
int cycid[MAXH][MAXW];
int cycpos[MAXH][MAXW][4];
int off[MAXID+1];
int px[MAXP],py[MAXP],pd[MAXP],np;
int occ[MAXH][MAXW][MAXFREQ],occpos[MAXH][MAXW][MAXFREQ],nocc[MAXH][MAXW];
set<pair<int,int> > common;

int normpos(int id,int pos) {
	int len=off[id+1]-off[id];
	while(pos<0) pos+=len; while(pos>=len) pos-=len; return pos;
}
void getp(int id,int pos,int &x,int &y,int &d) {
	x=px[off[id]+pos],y=py[off[id]+pos],d=pd[off[id]+pos];
}

int createcyc(int sx,int sy,int sd) {
	//printf("createcyc(%d,%d,%d)\n\t",sx,sy,sd);
	int x=sx,y=sy,d=sd,id=nid++; int len=0;
	while(true) {
		int p=np++; ++len; int nx,ny;
		if(sx==0&&sy==0&&sd==0&&x==h-1&&y==w-1&&d==1) d=4;
		if(sx==h-1&&sy==w-1&&sd==2&&x==0&&y==0&&d==3) d=4;
		while(d!=4) {
			nx=x+DX[d],ny=y+DY[d];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.') break;
			if(0<=nx&&nx<h&&0<=ny&&ny<w) { assert(cycid[nx][ny]==-1||cycid[nx][ny]==id); cycid[nx][ny]=id; }
			assert(cycpos[x][y][d]==-1||cycpos[x][y][d]==p-off[id]); cycpos[x][y][d]=p-off[id];
			d=(d+1)%4;
		}
		px[p]=x,py[p]=y,pd[p]=d;
		//printf("(%d,%d,%d)",x,y,d);
		if(d==4||nx==sx&&ny==sy) break;
		x=nx,y=ny,d=(d+3)%4;
	}
	//puts("");
	off[nid]=off[id]+len; return id;
}

void precalc() {
	nid=0,np=0; off[0]=0; memset(cycid,-1,sizeof(cycid)); memset(cycpos,-1,sizeof(cycpos)); memset(pid,-1,sizeof(pid));
	topid=createcyc(0,0,0);
	botid=createcyc(h-1,w-1,2);
	static int qx[MAXH*MAXW],qy[MAXH*MAXW],qhead,qtail; qhead=qtail=0; memset(reach,false,sizeof(reach)); qx[qhead]=0,qy[qhead]=0,++qhead,reach[0][0]=true;
	while(qtail<qhead) {
		int x=qx[qtail],y=qy[qtail]; ++qtail;
		REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.'&&!reach[nx][ny]) qx[qhead]=nx,qy[qhead]=ny,++qhead,reach[nx][ny]=true; }
	}
	REP(x,h) REP(y,w) if(reach[x][y]) REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]!='.'&&cycid[nx][ny]==-1) createcyc(x,y,k); }
	REP(x,h) REP(y,w) if(g[x][y]=='.') { int id=pid[x][y]=nid++; int p=np++; px[p]=x,py[p]=y,pd[p]=4; off[nid]=off[id]+1; }

	//REP(id,nid) if(off[id+1]-off[id]>1) { printf("%d:",id); FOR(j,off[id],off[id+1]) printf(" (%d,%d,%d)",px[j],py[j],pd[j]); puts(""); }
	memset(nocc,0,sizeof(nocc)); REP(id,nid) FOR(j,off[id],off[id+1]) { int x=px[j],y=py[j],d=pd[j]; int o=nocc[x][y]++; occ[x][y][o]=id; occpos[x][y][o]=j-off[id]; }
	common.clear(); REP(x,h) REP(y,w) REP(i,nocc[x][y]) REP(j,nocc[x][y]) if(occ[x][y][i]!=occ[x][y][j]) common.insert(MP(occ[x][y][i],occ[x][y][j])); common.erase(MP(topid,botid)); common.erase(MP(botid,topid));
	//for(set<pair<int,int> >::iterator it=common.begin();it!=common.end();++it) { int a=it->first,b=it->second; if(off[a+1]-off[a]<=1||off[b+1]-off[b]<=1) continue; printf("%d-%d\n",a,b); }
}

int nb,bx[MAXB],by[MAXB];
int bcnt[2][MAXB];
int bseg[MAXB],bsegpos[MAXB];
int q[MAXB],qhead,qtail;

typedef struct Seg { int id,l,r,len; int ndir; int prv,nxt; } Seg;
int shead[2];
Seg seg[2+9*MAXB]; int segcnt;
void printseg(int s) {
	int id=seg[s].id; if(off[id+1]-off[id]<=1) FOR(j,off[id],off[id+1]) printf("[%d,%d]",px[j],py[j]); else printf("(%d,%d..%d=[%d,%d]..[%d,%d])",seg[s].id,seg[s].l,seg[s].r,px[off[seg[s].id]+seg[s].l],py[off[seg[s].id]+seg[s].l],px[off[seg[s].id]+seg[s].r],py[off[seg[s].id]+seg[s].r]);
}
void printsegchain(int s) {
	while(s!=-1) { printseg(s); s=seg[s].nxt; } puts("");
}
int createseg(int id,int l,int r,int len,int ndir,int prv,int nxt) {
	int s=segcnt++; seg[s].id=id,seg[s].l=normpos(id,l),seg[s].r=normpos(id,r),seg[s].len=len;
	seg[s].ndir=ndir,seg[s].prv=prv,seg[s].nxt=nxt; return s;
}
void getsegp(int s,int pos,int &x,int &y,int &d) {
	while(pos<0) { assert(seg[s].prv!=-1); s=seg[s].prv; pos+=seg[s].len; }
	while(pos>=seg[s].len) { pos-=seg[s].len; assert(seg[s].nxt!=-1); s=seg[s].nxt; }
	getp(seg[s].id,normpos(seg[s].id,seg[s].l+pos),x,y,d); if(pos==seg[s].len-1) d=s[seg].ndir;
}
void splitseg(int s,int pos,int &pseg,int &nseg,int sd,int td) {
	assert(pos>=0&&pos<seg[s].len);
	nseg=createseg(seg[s].id,seg[s].l+pos+1,seg[s].r,seg[s].len-pos-1,td,-1,seg[s].nxt);
	REP(i,nb) if(bseg[i]==s&&bsegpos[i]>pos) bseg[i]=nseg,bsegpos[i]-=pos+1;
	pseg=s; seg[s].r=normpos(seg[s].id,seg[s].l+pos-1); seg[s].len=pos; seg[s].ndir=4; seg[s].nxt=-1;
	if(seg[pseg].len==0) { assert(seg[pseg].prv!=-1); pseg=seg[pseg].prv; seg[pseg].ndir=4; seg[pseg].nxt=-1; }
	if(seg[nseg].len==0) { assert(seg[nseg].nxt!=-1); nseg=seg[nseg].nxt; seg[nseg].prv=-1; }
}
int sappend(int prv,int id,int l,int r,int len,int dir) {
	assert(prv!=-1); int s=createseg(id,l,r,len,4,prv,-1); seg[prv].ndir=dir; seg[prv].nxt=s; return s;
}
void mergeseg(int prv,int nxt,int dir) {
	seg[prv].nxt=nxt; seg[nxt].prv=prv; seg[prv].ndir=dir;
}
bool segupdate(int at,int s) {
	//printf("\t\tsegupdate(%d,%d)=",at,s); printseg(s); puts("");
	for(int ss=shead[1-at];ss!=-1;ss=seg[ss].nxt) {
		//printf("\t\t\ttesting e[%d][%d]\n",seg[s].id,seg[ss].id);
		if(seg[s].id==seg[ss].id||common.count(MP(seg[s].id,seg[ss].id))) return false;
	}
	REP(i,nb) {
		int x=bx[i],y=by[i];
		REP(j,nocc[x][y]) if(occ[x][y][j]==seg[s].id) {
			int pos=occpos[x][y][j];
			if(seg[s].l<=seg[s].r&&(pos<seg[s].l||pos>seg[s].r)) continue;
			if(seg[s].l>seg[s].r&&seg[s].r<pos&&pos<seg[s].l) continue;
			//printf("\t\tfound block (%d,%d) in seg (%d,%d..%d) -> [%d,%d=>%d]\n",x,y,seg[s].id,seg[s].l,seg[s].r,s,pos-seg[s].l,normpos(seg[s].id,pos-seg[s].l));
			bcnt[at][i]++; bseg[i]=s; bsegpos[i]=normpos(seg[s].id,pos-seg[s].l);
			if(bcnt[at][i]==1) q[qhead++]=i;
			break;
		}
	}
	return true;
}

bool solve() {
	//printf("solving:"); REP(i,nb) printf(" (%d,%d)",bx[i],by[i]); puts("");
	qhead=qtail=0; segcnt=0; memset(bcnt,0,sizeof(bcnt));
	shead[0]=createseg(topid,0,off[topid+1]-off[topid]-1,off[topid+1]-off[topid],4,-1,-1);
	shead[1]=createseg(botid,0,off[botid+1]-off[botid]-1,off[botid+1]-off[botid],4,-1,-1);
	assert(segupdate(0,shead[0])); assert(segupdate(1,shead[1]));
	while(qtail<qhead) {
		int idx=q[qtail++];
		//printf("\tpath blocked by (%d,%d) [%d,%d]\n",bx[idx],by[idx],bseg[idx],bsegpos[idx]);
		assert(bcnt[0][idx]+bcnt[1][idx]>0);
		assert(bcnt[0][idx]==0||bcnt[1][idx]==0);
		int at=bcnt[0][idx]>0?0:1;
		if(bcnt[at][idx]!=1) continue;
		int sx,sy,sd,tx,ty,td; getsegp(bseg[idx],bsegpos[idx]-1,sx,sy,sd); getsegp(bseg[idx],bsegpos[idx]+1,tx,ty,td);
		//printf("\t(%d,%d,%d) / (%d,%d,%d)\n",sx,sy,sd,tx,ty,td);
		int pseg,nseg; splitseg(bseg[idx],bsegpos[idx],pseg,nseg,sd,td); int cseg=pseg;
		int cx=sx,cy=sy,cd=sd;
		while(true) {
			if(cx==tx&&cy==ty) { mergeseg(cseg,nseg,4); break; }
			if(cx+DX[cd]==bx[idx]&&cy+DY[cd]==by[idx]) cd=(cd+1)%4;
			int nx=cx+DX[cd],ny=cy+DY[cd]; assert(nx>=0&&nx<h&&ny>=0&&ny<w);
			if(g[nx][ny]=='.') {
				if(nx==tx&&ny==ty) { mergeseg(cseg,nseg,cd); break; }
				cseg=sappend(cseg,pid[nx][ny],0,0,1,cd);
				cx=nx,cy=ny,cd=(cd+3)%4;
			} else {
				int id=cycid[nx][ny],spos=cycpos[cx][cy][cd],cpos=spos,len=off[id+1]-off[id]; assert(id!=-1&&cpos!=-1);
				//printf("\t\tid=%d spos=%d len=%d\n",id,spos,len);
				int nd; getp(id,cpos,nx,ny,nd); assert(nx==cx&&ny==cy);
				{
					int ax,ay,ad; getsegp(cseg,seg[cseg].len-2,ax,ay,ad);
					if(nd==(ad^2)) cd=4; else cd=nd,spos=normpos(id,spos+1),--len;
				}
				while(nx!=bx[idx]||ny!=by[idx]) {
					cpos=normpos(id,cpos-1); --len;
					getp(id,cpos,nx,ny,nd);
				}
				int tpos=normpos(id,cpos-1); --len;
				getp(id,tpos,nx,ny,nd);
				if(nx==tx&&ny==ty) {
					int bx,by,bd; getp(id,normpos(id,tpos-1),bx,by,bd);
					if(td==(bd^2)) nd=4; else nd=bd,tpos=normpos(id,tpos-1),--len;
					cseg=sappend(cseg,id,spos,tpos,len,cd);
					mergeseg(cseg,nseg,nd); break;
				}
				cseg=sappend(cseg,id,spos,tpos,len,cd);
				cx=nx,cy=ny,cd=(nd+1)%4;
			}
		}
		//REP(i,2) { printf("\t%s: ",i==0?"TOP":"BOT"); printsegchain(shead[i]); }
		for(cseg=seg[pseg].nxt;cseg!=nseg;cseg=seg[cseg].nxt) if(!segupdate(at,cseg)) return false;
	}
	return true;
}

void run() {
	scanf("%d%d%d",&h,&w,&nq);
	REP(x,h) scanf("%s",g[x]);
	precalc();
	REP(i,nq) {
		scanf("%d",&nb); REP(j,nb) scanf("%d%d",&bx[j],&by[j]),--bx[j],--by[j];
		printf("%s\n",solve()?"YES":"NO"); fflush(stdout); //if(i==1) exit(0);
	}
}

int main() {
	run();
	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=1000;
const int MAXW=1000;
const int MAXB=10;
const int MAXID=2*MAXH*MAXW+2;
const int MAXFREQ=6;
const int MAXP=MAXFREQ*MAXH*MAXW;
const int DX[]={-1,0,+1,0,0},DY[]={0,+1,0,-1,0};

int h,w,nq;
char g[MAXH][MAXW+1];
bool reach[MAXH][MAXW];

int nid;
int pid[MAXH][MAXW];
int topid,botid;
int cycid[MAXH][MAXW];
int cycpos[MAXH][MAXW][4];
int off[MAXID+1];
int px[MAXP],py[MAXP],pd[MAXP],np;
int occ[MAXH][MAXW][MAXFREQ],occpos[MAXH][MAXW][MAXFREQ],nocc[MAXH][MAXW];
set<ll> common;

int normpos(int id,int pos) {
	int len=off[id+1]-off[id];
	while(pos<0) pos+=len; while(pos>=len) pos-=len; return pos;
}
void getp(int id,int pos,int &x,int &y,int &d) {
	x=px[off[id]+pos],y=py[off[id]+pos],d=pd[off[id]+pos];
}

int createcyc(int sx,int sy,int sd) {
	//printf("createcyc(%d,%d,%d)\n\t",sx,sy,sd);
	int x=sx,y=sy,d=sd,id=nid++; int len=0;
	while(true) {
		int p=np++; ++len; int nx,ny;
		if(sx==0&&sy==0&&sd==0&&x==h-1&&y==w-1&&d==1) d=4;
		if(sx==h-1&&sy==w-1&&sd==2&&x==0&&y==0&&d==3) d=4;
		while(d!=4) {
			nx=x+DX[d],ny=y+DY[d];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.') break;
			if(0<=nx&&nx<h&&0<=ny&&ny<w) { assert(cycid[nx][ny]==-1||cycid[nx][ny]==id); cycid[nx][ny]=id; }
			assert(cycpos[x][y][d]==-1||cycpos[x][y][d]==p-off[id]); cycpos[x][y][d]=p-off[id];
			d=(d+1)%4;
		}
		px[p]=x,py[p]=y,pd[p]=d;
		//printf("(%d,%d,%d)",x,y,d);
		if(d==4||nx==sx&&ny==sy) break;
		x=nx,y=ny,d=(d+3)%4;
	}
	//puts("");
	off[nid]=off[id]+len; return id;
}

void precalc() {
	nid=0,np=0; off[0]=0; memset(cycid,-1,sizeof(cycid)); memset(cycpos,-1,sizeof(cycpos)); memset(pid,-1,sizeof(pid));
	topid=createcyc(0,0,0);
	botid=createcyc(h-1,w-1,2);
	static int qx[MAXH*MAXW],qy[MAXH*MAXW],qhead,qtail; qhead=qtail=0; memset(reach,false,sizeof(reach)); qx[qhead]=0,qy[qhead]=0,++qhead,reach[0][0]=true;
	while(qtail<qhead) {
		int x=qx[qtail],y=qy[qtail]; ++qtail;
		REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.'&&!reach[nx][ny]) qx[qhead]=nx,qy[qhead]=ny,++qhead,reach[nx][ny]=true; }
	}
	REP(x,h) REP(y,w) if(reach[x][y]) REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]!='.'&&cycid[nx][ny]==-1) createcyc(x,y,k); }
	REP(x,h) REP(y,w) if(g[x][y]=='.') { int id=pid[x][y]=nid++; int p=np++; px[p]=x,py[p]=y,pd[p]=4; off[nid]=off[id]+1; }

	//REP(id,nid) if(off[id+1]-off[id]>1) { printf("%d:",id); FOR(j,off[id],off[id+1]) printf(" (%d,%d,%d)",px[j],py[j],pd[j]); puts(""); }
	memset(nocc,0,sizeof(nocc)); REP(id,nid) FOR(j,off[id],off[id+1]) { int x=px[j],y=py[j],d=pd[j]; int o=nocc[x][y]++; occ[x][y][o]=id; occpos[x][y][o]=j-off[id]; }
	common.clear(); REP(x,h) REP(y,w) REP(i,nocc[x][y]) REP(j,nocc[x][y]) if(occ[x][y][i]<occ[x][y][j]) common.insert((ll)nid*occ[x][y][i]+occ[x][y][j]); common.erase((ll)nid*topid+botid); common.erase((ll)nid*botid+topid);
	//for(set<pair<int,int> >::iterator it=common.begin();it!=common.end();++it) { int a=it->first,b=it->second; if(off[a+1]-off[a]<=1||off[b+1]-off[b]<=1) continue; printf("%d-%d\n",a,b); }
}

int nb,bx[MAXB],by[MAXB];
int bcnt[2][MAXB];
int bseg[MAXB],bsegpos[MAXB];
int q[MAXB],qhead,qtail;

typedef struct Seg { int id,l,r,len; int ndir; int prv,nxt; } Seg;
int shead[2];
Seg seg[2+9*MAXB]; int segcnt;
void printseg(int s) {
	int id=seg[s].id; if(off[id+1]-off[id]<=1) FOR(j,off[id],off[id+1]) printf("[%d,%d]",px[j],py[j]); else printf("(%d,%d..%d=[%d,%d]..[%d,%d])",seg[s].id,seg[s].l,seg[s].r,px[off[seg[s].id]+seg[s].l],py[off[seg[s].id]+seg[s].l],px[off[seg[s].id]+seg[s].r],py[off[seg[s].id]+seg[s].r]);
}
void printsegchain(int s) {
	puts(""); while(s!=-1) { printf("\t%d:<%d,%d,%d|%d>",s,seg[s].prv,seg[s].nxt,seg[s].len,seg[s].ndir); printseg(s); puts(""); s=seg[s].nxt; } puts("");
}
int createseg(int id,int l,int r,int len,int ndir,int prv,int nxt) {
	int s=segcnt++; seg[s].id=id,seg[s].l=normpos(id,l),seg[s].r=normpos(id,r),seg[s].len=len;
	seg[s].ndir=ndir,seg[s].prv=prv,seg[s].nxt=nxt; return s;
}
void getsegp(int s,int pos,int &x,int &y,int &d) {
	while(pos<0) { assert(seg[s].prv!=-1); s=seg[s].prv; pos+=seg[s].len; }
	while(pos>=seg[s].len) { pos-=seg[s].len; assert(seg[s].nxt!=-1); s=seg[s].nxt; }
	getp(seg[s].id,normpos(seg[s].id,seg[s].l+pos),x,y,d); if(pos==seg[s].len-1) d=s[seg].ndir;
}
void splitseg(int s,int pos,int &pseg,int &nseg,int sd,int td) {
	assert(pos>=0&&pos<seg[s].len);
	nseg=createseg(seg[s].id,seg[s].l+pos+1,seg[s].r,seg[s].len-pos-1,seg[s].ndir,-1,seg[s].nxt); if(seg[nseg].nxt!=-1) seg[seg[nseg].nxt].prv=nseg;
	REP(i,nb) if(bseg[i]==s&&bsegpos[i]>pos) bseg[i]=nseg,bsegpos[i]-=pos+1;
	pseg=s; seg[s].r=normpos(seg[s].id,seg[s].l+pos-1); seg[s].len=pos; seg[s].ndir=4; seg[s].nxt=-1;
	if(seg[pseg].len==0) { assert(seg[pseg].prv!=-1); pseg=seg[pseg].prv; seg[pseg].ndir=4; seg[pseg].nxt=-1; }
	if(seg[nseg].len==0) { assert(seg[nseg].nxt!=-1); nseg=seg[nseg].nxt; seg[nseg].prv=-1; }
}
int sappend(int prv,int id,int l,int r,int len,int dir) {
	assert(prv!=-1); int s=createseg(id,l,r,len,4,prv,-1); seg[prv].ndir=dir; seg[prv].nxt=s; return s;
}
void mergeseg(int prv,int nxt,int dir) {
	seg[prv].nxt=nxt; seg[nxt].prv=prv; seg[prv].ndir=dir;
}
bool segupdate(int at,int s) {
	//printf("\t\tsegupdate(%d,%d)=",at,s); printseg(s); puts("");
	for(int ss=shead[1-at];ss!=-1;ss=seg[ss].nxt) {
		//printf("\t\t\ttesting e[%d][%d]\n",seg[s].id,seg[ss].id);
		int a=seg[s].id,b=seg[ss].id; if(a>b) swap(a,b);
		if(seg[s].id==seg[ss].id||common.count((ll)nid*a+b)) return false;
	}
	REP(i,nb) {
		int x=bx[i],y=by[i];
		REP(j,nocc[x][y]) if(occ[x][y][j]==seg[s].id) {
			int pos=occpos[x][y][j];
			if(seg[s].l<=seg[s].r&&(pos<seg[s].l||pos>seg[s].r)) continue;
			if(seg[s].l>seg[s].r&&seg[s].r<pos&&pos<seg[s].l) continue;
			//printf("\t\tfound block (%d,%d) in seg (%d,%d..%d) -> [%d,%d=>%d]\n",x,y,seg[s].id,seg[s].l,seg[s].r,s,pos-seg[s].l,normpos(seg[s].id,pos-seg[s].l));
			bcnt[at][i]++; bseg[i]=s; bsegpos[i]=normpos(seg[s].id,pos-seg[s].l);
			if(bcnt[at][i]==1) q[qhead++]=i;
			break;
		}
	}
	return true;
}

bool solve() {
	//printf("solving:"); REP(i,nb) printf(" (%d,%d)",bx[i],by[i]); puts("");
	qhead=qtail=0; segcnt=0; memset(bcnt,0,sizeof(bcnt));
	shead[0]=createseg(topid,0,off[topid+1]-off[topid]-1,off[topid+1]-off[topid],4,-1,-1);
	shead[1]=createseg(botid,0,off[botid+1]-off[botid]-1,off[botid+1]-off[botid],4,-1,-1);
	assert(segupdate(0,shead[0])); assert(segupdate(1,shead[1]));
	while(qtail<qhead) {
		int idx=q[qtail++];
		//printf("\tpath blocked by (%d,%d) [%d,%d]\n",bx[idx],by[idx],bseg[idx],bsegpos[idx]);
		assert(bcnt[0][idx]+bcnt[1][idx]>0);
		assert(bcnt[0][idx]==0||bcnt[1][idx]==0);
		int at=bcnt[0][idx]>0?0:1;
		if(bcnt[at][idx]!=1) continue;
		int sx,sy,sd,tx,ty,td; getsegp(bseg[idx],bsegpos[idx]-1,sx,sy,sd); getsegp(bseg[idx],bsegpos[idx]+1,tx,ty,td);
		//printf("\t(%d,%d,%d) / (%d,%d,%d)\n",sx,sy,sd,tx,ty,td);
		int pseg,nseg; splitseg(bseg[idx],bsegpos[idx],pseg,nseg,sd,td); int cseg=pseg;
		int cx=sx,cy=sy,cd=sd; //int tmp=0;
		while(true) {
			//printf("cx=%d cy=%d cd=%d\n",cx,cy,cd); if(++tmp>10) exit(0);
			if(cx==tx&&cy==ty) { mergeseg(cseg,nseg,4); break; }
			if(cx+DX[cd]==bx[idx]&&cy+DY[cd]==by[idx]) cd=(cd+1)%4;
			int nx=cx+DX[cd],ny=cy+DY[cd]; assert(nx>=0&&nx<h&&ny>=0&&ny<w);
			if(g[nx][ny]=='.') {
				if(nx==tx&&ny==ty) { mergeseg(cseg,nseg,cd); break; }
				cseg=sappend(cseg,pid[nx][ny],0,0,1,cd);
				cx=nx,cy=ny,cd=(cd+3)%4;
			} else {
				int id=cycid[nx][ny],spos=cycpos[cx][cy][cd],cpos=spos,len=off[id+1]-off[id]; assert(id!=-1&&cpos!=-1);
				//printf("\t\tid=%d spos=%d len=%d\n",id,spos,len);
				int nd; getp(id,cpos,nx,ny,nd); assert(nx==cx&&ny==cy);
				{
					int ax,ay,ad; getsegp(cseg,seg[cseg].len-2,ax,ay,ad);
					if(nd==(ad^2)) cd=4; else cd=nd,spos=normpos(id,spos+1),--len;
				}
				while(nx!=bx[idx]||ny!=by[idx]) {
					cpos=normpos(id,cpos-1); --len;
					getp(id,cpos,nx,ny,nd);
				}
				int tpos=normpos(id,cpos-1); --len;
				getp(id,tpos,nx,ny,nd);
				if(nx==tx&&ny==ty) {
					int bx,by,bd; getp(id,normpos(id,tpos-1),bx,by,bd);
					if(td==(bd^2)) nd=4; else nd=bd,tpos=normpos(id,tpos-1),--len;
					cseg=sappend(cseg,id,spos,tpos,len,cd);
					mergeseg(cseg,nseg,nd); break;
				}
				cseg=sappend(cseg,id,spos,tpos,len,cd);
				cx=nx,cy=ny,cd=(nd+1)%4;
			}
		}
		//REP(i,2) { printf("\t%s: ",i==0?"TOP":"BOT"); printsegchain(shead[i]); }
		for(cseg=seg[pseg].nxt;cseg!=nseg;cseg=seg[cseg].nxt) if(!segupdate(at,cseg)) return false;
	}
	return true;
}

void run() {
	scanf("%d%d%d",&h,&w,&nq);
	REP(x,h) scanf("%s",g[x]);
	//h=MAXH; w=MAXW; REP(x,h) REP(y,w) g[x][y]=(x%2==1&&y%2==1&&(x!=h-1||y!=w-1))?'#':'.'; g[2][2]='#';
	precalc();
	//int mxocc=0; REP(x,h) REP(y,w) if(nocc[x][y]>mxocc) mxocc=nocc[x][y]; printf("nid=%d np=%d (%.9lf) mxocc=%d\n",nid,np,1.0*np/w/h,mxocc); exit(0);
	/*if(nq==0) {
		vector<pair<int,int> > all; REP(x,h) REP(y,w) if(g[x][y]=='.'&&(x!=0||y!=0)&&(x!=h-1||y!=w-1)) all.PB(MP(x,y));
		while(true) {
			nb=rand()%10+1;
			REP(i,nb) {
				int idx=i+rand()%(SZ(all)-i);
				swap(all[i],all[idx]); bx[i]=all[i].first,by[i]=all[i].second;
			}
			//printf("%d\n",nb); REP(i,nb) printf("%d %d\n",bx[i]+1,by[i]+1);
			printf("%s\n",solve()?"YES":"NO"); fflush(stdout);
		}
	}*/
	REP(i,nq) {
		scanf("%d",&nb); REP(j,nb) scanf("%d%d",&bx[j],&by[j]),--bx[j],--by[j];
		printf("%s\n",solve()?"YES":"NO"); fflush(stdout);
	}
}

int main() {
	run();
	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=1000;
const int MAXW=1000;
const int MAXB=10;
const int MAXID=2*MAXH*MAXW+2;
const int MAXFREQ=12;
const int MAXP=MAXFREQ*MAXH*MAXW;
const int DX[]={-1,0,+1,0,0},DY[]={0,+1,0,-1,0};

int h,w,nq;
char g[MAXH][MAXW+1];
bool reach[MAXH][MAXW];

int nid;
int pid[MAXH][MAXW];
int topid,botid;
int cycid[MAXH][MAXW];
int cycpos[MAXH][MAXW][4];
int off[MAXID+1];
int px[MAXP],py[MAXP],pd[MAXP],np;
int occ[MAXH][MAXW][MAXFREQ],occpos[MAXH][MAXW][MAXFREQ],nocc[MAXH][MAXW];
set<pair<int,int> > common;

int normpos(int id,int pos) {
	int len=off[id+1]-off[id];
	while(pos<0) pos+=len; while(pos>=len) pos-=len; return pos;
}
void getp(int id,int pos,int &x,int &y,int &d) {
	x=px[off[id]+pos],y=py[off[id]+pos],d=pd[off[id]+pos];
}

int createcyc(int sx,int sy,int sd) {
	//printf("createcyc(%d,%d,%d)\n\t",sx,sy,sd);
	int x=sx,y=sy,d=sd,id=nid++; int len=0;
	while(true) {
		int p=np++; ++len; int nx,ny;
		if(sx==0&&sy==0&&sd==0&&x==h-1&&y==w-1&&d==1) d=4;
		if(sx==h-1&&sy==w-1&&sd==2&&x==0&&y==0&&d==3) d=4;
		while(d!=4) {
			nx=x+DX[d],ny=y+DY[d];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.') break;
			if(0<=nx&&nx<h&&0<=ny&&ny<w) { assert(cycid[nx][ny]==-1||cycid[nx][ny]==id); cycid[nx][ny]=id; }
			assert(cycpos[x][y][d]==-1||cycpos[x][y][d]==p-off[id]); cycpos[x][y][d]=p-off[id];
			d=(d+1)%4;
		}
		px[p]=x,py[p]=y,pd[p]=d;
		//printf("(%d,%d,%d)",x,y,d);
		if(d==4||nx==sx&&ny==sy) break;
		x=nx,y=ny,d=(d+3)%4;
	}
	//puts("");
	off[nid]=off[id]+len; return id;
}

void precalc() {
	nid=0,np=0; off[0]=0; memset(cycid,-1,sizeof(cycid)); memset(cycpos,-1,sizeof(cycpos)); memset(pid,-1,sizeof(pid));
	topid=createcyc(0,0,0);
	botid=createcyc(h-1,w-1,2);
	static int qx[MAXH*MAXW],qy[MAXH*MAXW],qhead,qtail; qhead=qtail=0; memset(reach,false,sizeof(reach)); qx[qhead]=0,qy[qhead]=0,++qhead,reach[0][0]=true;
	while(qtail<qhead) {
		int x=qx[qtail],y=qy[qtail]; ++qtail;
		REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.'&&!reach[nx][ny]) qx[qhead]=nx,qy[qhead]=ny,++qhead,reach[nx][ny]=true; }
	}
	REP(x,h) REP(y,w) if(reach[x][y]) REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]!='.'&&cycid[nx][ny]==-1) createcyc(x,y,k); }
	REP(x,h) REP(y,w) if(g[x][y]=='.') { int id=pid[x][y]=nid++; int p=np++; px[p]=x,py[p]=y,pd[p]=4; off[nid]=off[id]+1; }

	//REP(id,nid) if(off[id+1]-off[id]>1) { printf("%d:",id); FOR(j,off[id],off[id+1]) printf(" (%d,%d,%d)",px[j],py[j],pd[j]); puts(""); }
	memset(nocc,0,sizeof(nocc)); REP(id,nid) FOR(j,off[id],off[id+1]) { int x=px[j],y=py[j],d=pd[j]; int o=nocc[x][y]++; occ[x][y][o]=id; occpos[x][y][o]=j-off[id]; }
	common.clear(); REP(x,h) REP(y,w) REP(i,nocc[x][y]) REP(j,nocc[x][y]) if(occ[x][y][i]!=occ[x][y][j]) common.insert(MP(occ[x][y][i],occ[x][y][j])); common.erase(MP(topid,botid)); common.erase(MP(botid,topid));
	//for(set<pair<int,int> >::iterator it=common.begin();it!=common.end();++it) { int a=it->first,b=it->second; if(off[a+1]-off[a]<=1||off[b+1]-off[b]<=1) continue; printf("%d-%d\n",a,b); }
}

int nb,bx[MAXB],by[MAXB];
int bcnt[2][MAXB];
int bseg[MAXB],bsegpos[MAXB];
int q[MAXB],qhead,qtail;

typedef struct Seg { int id,l,r,len; int ndir; int prv,nxt; } Seg;
int shead[2];
Seg seg[2+9*MAXB]; int segcnt;
void printseg(int s) {
	int id=seg[s].id; if(off[id+1]-off[id]<=1) FOR(j,off[id],off[id+1]) printf("[%d,%d]",px[j],py[j]); else printf("(%d,%d..%d=[%d,%d]..[%d,%d])",seg[s].id,seg[s].l,seg[s].r,px[off[seg[s].id]+seg[s].l],py[off[seg[s].id]+seg[s].l],px[off[seg[s].id]+seg[s].r],py[off[seg[s].id]+seg[s].r]);
}
void printsegchain(int s) {
	while(s!=-1) { printseg(s); s=seg[s].nxt; } puts("");
}
int createseg(int id,int l,int r,int len,int ndir,int prv,int nxt) {
	int s=segcnt++; seg[s].id=id,seg[s].l=normpos(id,l),seg[s].r=normpos(id,r),seg[s].len=len;
	seg[s].ndir=ndir,seg[s].prv=prv,seg[s].nxt=nxt; return s;
}
void getsegp(int s,int pos,int &x,int &y,int &d) {
	while(pos<0) { assert(seg[s].prv!=-1); s=seg[s].prv; pos+=seg[s].len; }
	while(pos>=seg[s].len) { pos-=seg[s].len; assert(seg[s].nxt!=-1); s=seg[s].nxt; }
	getp(seg[s].id,normpos(seg[s].id,seg[s].l+pos),x,y,d); if(pos==seg[s].len-1) d=s[seg].ndir;
}
void splitseg(int s,int pos,int &pseg,int &nseg,int sd,int td) {
	assert(pos>=0&&pos<seg[s].len);
	nseg=createseg(seg[s].id,seg[s].l+pos+1,seg[s].r,seg[s].len-pos-1,td,-1,seg[s].nxt);
	REP(i,nb) if(bseg[i]==s&&bsegpos[i]>pos) bseg[i]=nseg,bsegpos[i]-=pos+1;
	pseg=s; seg[s].r=normpos(seg[s].id,seg[s].l+pos-1); seg[s].len=pos; seg[s].ndir=4; seg[s].nxt=-1;
	if(seg[pseg].len==0) { assert(seg[pseg].prv!=-1); pseg=seg[pseg].prv; seg[pseg].ndir=4; seg[pseg].nxt=-1; }
	if(seg[nseg].len==0) { assert(seg[nseg].nxt!=-1); nseg=seg[nseg].nxt; seg[nseg].prv=-1; }
}
int sappend(int prv,int id,int l,int r,int len,int dir) {
	assert(prv!=-1); int s=createseg(id,l,r,len,4,prv,-1); seg[prv].ndir=dir; seg[prv].nxt=s; return s;
}
void mergeseg(int prv,int nxt,int dir) {
	seg[prv].nxt=nxt; seg[nxt].prv=prv; seg[prv].ndir=dir;
}
bool segupdate(int at,int s) {
	//printf("\t\tsegupdate(%d,%d)=",at,s); printseg(s); puts("");
	for(int ss=shead[1-at];ss!=-1;ss=seg[ss].nxt) {
		//printf("\t\t\ttesting e[%d][%d]\n",seg[s].id,seg[ss].id);
		if(seg[s].id==seg[ss].id||common.count(MP(seg[s].id,seg[ss].id))) return false;
	}
	REP(i,nb) {
		int x=bx[i],y=by[i];
		REP(j,nocc[x][y]) if(occ[x][y][j]==seg[s].id) {
			int pos=occpos[x][y][j];
			if(seg[s].l<=seg[s].r&&(pos<seg[s].l||pos>seg[s].r)) continue;
			if(seg[s].l>seg[s].r&&seg[s].r<pos&&pos<seg[s].l) continue;
			//printf("\t\tfound block (%d,%d) in seg (%d,%d..%d) -> [%d,%d=>%d]\n",x,y,seg[s].id,seg[s].l,seg[s].r,s,pos-seg[s].l,normpos(seg[s].id,pos-seg[s].l));
			bcnt[at][i]++; bseg[i]=s; bsegpos[i]=normpos(seg[s].id,pos-seg[s].l);
			if(bcnt[at][i]==1) q[qhead++]=i;
			break;
		}
	}
	return true;
}

bool solve() {
	//printf("solving:"); REP(i,nb) printf(" (%d,%d)",bx[i],by[i]); puts("");
	qhead=qtail=0; segcnt=0; memset(bcnt,0,sizeof(bcnt));
	shead[0]=createseg(topid,0,off[topid+1]-off[topid]-1,off[topid+1]-off[topid],4,-1,-1);
	shead[1]=createseg(botid,0,off[botid+1]-off[botid]-1,off[botid+1]-off[botid],4,-1,-1);
	assert(segupdate(0,shead[0])); assert(segupdate(1,shead[1]));
	while(qtail<qhead) {
		int idx=q[qtail++];
		//printf("\tpath blocked by (%d,%d) [%d,%d]\n",bx[idx],by[idx],bseg[idx],bsegpos[idx]);
		assert(bcnt[0][idx]+bcnt[1][idx]>0);
		assert(bcnt[0][idx]==0||bcnt[1][idx]==0);
		int at=bcnt[0][idx]>0?0:1;
		if(bcnt[at][idx]!=1) continue;
		int sx,sy,sd,tx,ty,td; getsegp(bseg[idx],bsegpos[idx]-1,sx,sy,sd); getsegp(bseg[idx],bsegpos[idx]+1,tx,ty,td);
		//printf("\t(%d,%d,%d) / (%d,%d,%d)\n",sx,sy,sd,tx,ty,td);
		int pseg,nseg; splitseg(bseg[idx],bsegpos[idx],pseg,nseg,sd,td); int cseg=pseg;
		int cx=sx,cy=sy,cd=sd;
		while(true) {
			if(cx==tx&&cy==ty) { mergeseg(cseg,nseg,4); break; }
			if(cx+DX[cd]==bx[idx]&&cy+DY[cd]==by[idx]) cd=(cd+1)%4;
			int nx=cx+DX[cd],ny=cy+DY[cd]; assert(nx>=0&&nx<h&&ny>=0&&ny<w);
			if(g[nx][ny]=='.') {
				if(nx==tx&&ny==ty) { mergeseg(cseg,nseg,cd); break; }
				cseg=sappend(cseg,pid[nx][ny],0,0,1,cd);
				cx=nx,cy=ny,cd=(cd+3)%4;
			} else {
				int id=cycid[nx][ny],spos=cycpos[cx][cy][cd],cpos=spos,len=off[id+1]-off[id]; assert(id!=-1&&cpos!=-1);
				//printf("\t\tid=%d spos=%d len=%d\n",id,spos,len);
				int nd; getp(id,cpos,nx,ny,nd); assert(nx==cx&&ny==cy);
				{
					int ax,ay,ad; getsegp(cseg,seg[cseg].len-2,ax,ay,ad);
					if(nd==(ad^2)) cd=4; else cd=nd,spos=normpos(id,spos+1),--len;
				}
				while(nx!=bx[idx]||ny!=by[idx]) {
					cpos=normpos(id,cpos-1); --len;
					getp(id,cpos,nx,ny,nd);
				}
				int tpos=normpos(id,cpos-1); --len;
				getp(id,tpos,nx,ny,nd);
				if(nx==tx&&ny==ty) {
					int bx,by,bd; getp(id,normpos(id,tpos-1),bx,by,bd);
					if(td==(bd^2)) nd=4; else nd=bd,tpos=normpos(id,tpos-1),--len;
					cseg=sappend(cseg,id,spos,tpos,len,cd);
					mergeseg(cseg,nseg,nd); break;
				}
				cseg=sappend(cseg,id,spos,tpos,len,cd);
				cx=nx,cy=ny,cd=(nd+1)%4;
			}
		}
		//REP(i,2) { printf("\t%s: ",i==0?"TOP":"BOT"); printsegchain(shead[i]); }
		for(cseg=seg[pseg].nxt;cseg!=nseg;cseg=seg[cseg].nxt) if(!segupdate(at,cseg)) return false;
	}
	return true;
}

void run() {
	scanf("%d%d%d",&h,&w,&nq);
	REP(x,h) scanf("%s",g[x]);
	precalc();
	REP(i,nq) {
		scanf("%d",&nb); REP(j,nb) scanf("%d%d",&bx[j],&by[j]),--bx[j],--by[j];
		printf("%s\n",solve()?"YES":"NO"); fflush(stdout); //if(i==1) exit(0);
	}
}

int main() {
	run();
	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=1000;
const int MAXW=1000;
const int MAXB=10;
const int MAXSEG=2+9*MAXB;
const int MAXC=2*MAXH*MAXW+2;
const int MAXFREQ=5;
const int MAXP=MAXFREQ*MAXH*MAXW;
const int DX[]={-1,0,+1,0},DY[]={0,+1,0,-1};

int h,w,nq;
char g[MAXH][MAXW+1];
int ncyc;
int clen[MAXC];
int coff[MAXC+1];
int np;
int px[MAXP],py[MAXP],pd[MAXP];
int pcyc[MAXH][MAXW][MAXFREQ],pcycidx[MAXH][MAXW][MAXFREQ],pcyccnt[MAXH][MAXW];
int topcyc,botcyc;
int xycyc[MAXH][MAXW];
int xydcyc[MAXH][MAXW][4],xydcycidx[MAXH][MAXW][4];
set<ll> common;

int normidx(int c,int idx) { while(idx<0) idx+=clen[c]; while(idx>=clen[c]) idx-=clen[c]; return idx; }
int getcycx(int c,int idx) { return px[coff[c]+idx]; }
int getcycy(int c,int idx) { return py[coff[c]+idx]; }
int getcycd(int c,int idx) { return pd[coff[c]+idx]; }

int createcyc(int sx,int sy,int sd) {
	//printf("createcyc(%d,%d,%d)\n\t",sx,sy,sd);
	int x=sx,y=sy,d=sd,c=ncyc++; clen[c]=0;
	while(true) {
		int p=np++; ++clen[c]; int nx,ny;
		if(sx==0&&sy==0&&sd==0&&x==h-1&&y==w-1&&d==1) d=4;
		if(sx==h-1&&sy==w-1&&sd==2&&x==0&&y==0&&d==3) d=4;
		while(d!=4) {
			nx=x+DX[d],ny=y+DY[d];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.') break;
			assert(xydcyc[x][y][d]==-1); xydcyc[x][y][d]=c; xydcycidx[x][y][d]=p-coff[c];
			d=(d+1)%4;
		}
		px[p]=x,py[p]=y,pd[p]=d;
		//printf("(%d,%d,%d)",x,y,d);
		if(d==4||nx==sx&&ny==sy) break;
		x=nx,y=ny,d=(d+3)%4;
	}
	//puts("");
	coff[ncyc]=coff[c]+clen[c]; return c;
}
void precalc() {
	ncyc=0,np=0; coff[0]=0; memset(xydcyc,-1,sizeof(xydcyc)); memset(xydcycidx,-1,sizeof(xydcycidx)); memset(xycyc,-1,sizeof(xycyc));
	topcyc=createcyc(0,0,0);
	botcyc=createcyc(h-1,w-1,2);
	static int qx[MAXH*MAXW],qy[MAXH*MAXW],qhead,qtail; static bool reach[MAXH][MAXW]; qhead=qtail=0; memset(reach,false,sizeof(reach)); qx[qhead]=0,qy[qhead]=0,++qhead,reach[0][0]=true;
	while(qtail<qhead) {
		int x=qx[qtail],y=qy[qtail]; ++qtail;
		REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.'&&!reach[nx][ny]) qx[qhead]=nx,qy[qhead]=ny,++qhead,reach[nx][ny]=true; }
	}
	REP(x,h) REP(y,w) if(reach[x][y]) REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]!='.'&&xydcyc[x][y][k]==-1) createcyc(x,y,k); }
	REP(x,h) REP(y,w) if(g[x][y]=='.') { int c=xycyc[x][y]=ncyc++; int p=np++; px[p]=x,py[p]=y,pd[p]=4; clen[c]=1; coff[ncyc]=coff[c]+clen[c]; }

	//REP(c,ncyc) if(clen[c]>1) { printf("%d:",c); FOR(j,coff[c],coff[c+1]) printf(" (%d,%d,%d)",px[j],py[j],pd[j]); puts(""); }
	memset(pcyccnt,0,sizeof(pcyccnt)); REP(c,ncyc) FOR(j,coff[c],coff[c+1]) { int x=px[j],y=py[j],d=pd[j]; int i=pcyccnt[x][y]++; pcyc[x][y][i]=c; pcycidx[x][y][i]=j-coff[c]; }
	common.clear(); REP(x,h) REP(y,w) REP(i,pcyccnt[x][y]) REP(j,pcyccnt[x][y]) if(pcyc[x][y][i]<pcyc[x][y][j]) common.insert((ll)ncyc*pcyc[x][y][i]+pcyc[x][y][j]); common.erase((ll)ncyc*topcyc+botcyc); common.erase((ll)ncyc*botcyc+topcyc);
	//for(set<pair<int,int> >::iterator it=common.begin();it!=common.end();++it) { int a=it->first,b=it->second; if(off[a+1]-off[a]<=1||off[b+1]-off[b]<=1) continue; printf("%d-%d\n",a,b); }
}

typedef struct Seg { int cyc,l,r,len,nd,prv,nxt; } Seg;

int nb;
int bx[MAXB],by[MAXB];
int bcnt[MAXB],bat[MAXB],bseg[MAXB],bpos[MAXB];
int q[4*MAXB],qhead,qtail;

int shead[2];
Seg seg[MAXSEG]; int scnt;

void printpath(int s) {
	while(seg[s].prv!=-1) s=seg[s].prv;
	for(;s!=-1;s=seg[s].nxt) {
		printf("\t\t[%d,%d]",getcycx(seg[s].cyc,seg[s].l),getcycy(seg[s].cyc,seg[s].l)); if(seg[s].l!=seg[s].r) printf("-[%d,%d]",getcycx(seg[s].cyc,seg[s].r),getcycy(seg[s].cyc,seg[s].r));
		printf("<%d-%d-%d>(%d)\n",seg[s].prv,s,seg[s].nxt,seg[s].len);
	}
}
int createseg(int cyc,int l,int r,int len,int nd) { seg[scnt].cyc=cyc,seg[scnt].l=l,seg[scnt].r=r,seg[scnt].len=len,seg[scnt].nd=nd,seg[scnt].prv=seg[scnt].nxt=-1; return scnt++; }
bool xyoncyc(int x,int y,int i,int c) {
	return pcyc[x][y][i]==c;
}
int getxycycpos(int x,int y,int i,int c) {
	return pcycidx[x][y][i];
}
bool xyonseg(int x,int y,int i,int s) {
	if(pcyc[x][y][i]==seg[s].cyc) {
		int idx=pcycidx[x][y][i];
		if(seg[s].l<=seg[s].r&&seg[s].l<=idx&&idx<=seg[s].r) return true;
		if(seg[s].l>seg[s].r&&(idx<=seg[s].r||idx>=seg[s].l)) return true;
	}
	return false;
}
int getxysegpos(int x,int y,int i,int s) {
	if(pcyc[x][y][i]==seg[s].cyc) {
		int idx=pcycidx[x][y][i];
		if(seg[s].l<=seg[s].r&&seg[s].l<=idx&&idx<=seg[s].r) return idx-seg[s].l;
		if(seg[s].l>seg[s].r&&(idx<=seg[s].r||idx>=seg[s].l)) return idx-seg[s].l+(idx<=seg[s].r?clen[seg[s].cyc]:0);
	}
	assert(false); return -1;
}
bool bonseg(int b,int i,int s) { return xyonseg(bx[b],by[b],i,s); }
bool banyonseg(int b,int s) {
	REP(j,pcyccnt[bx[b]][by[b]]) if(bonseg(b,j,s)) return true;
	return false;
}
int getbsegpos(int b,int i,int s) { return getxysegpos(bx[b],by[b],i,s); }
int getonlybsegpos(int b,int s) {
	int ret=-1; REP(j,pcyccnt[bx[b]][by[b]]) if(bonseg(b,j,s)) { assert(ret==-1); ret=getbsegpos(b,j,s); } assert(ret!=-1); return ret;
}
int findnxtcycpos(int c,int idx,int x,int y) {
	int ret=-1;
	//printf("findnxtcycpos(%d,%d,%d,%d)\n",c,idx,x,y);
	REP(j,pcyccnt[x][y]) if(xyoncyc(x,y,j,c)) {
		int cur=getxycycpos(x,y,j,c); //printf("\t%d\n",cur);
		if(ret==-1||(ret>=idx&&cur>=idx&&cur<ret||ret<idx&&(cur>=idx||cur<ret))) ret=cur;
	}
	assert(ret!=-1); return ret;
}
void getsegxyd(int s,int pos,int &x,int &y,int &d) {
	int idx=normidx(seg[s].cyc,seg[s].l+pos);
	x=getcycx(seg[s].cyc,idx),y=getcycy(seg[s].cyc,idx),d=pos==seg[s].len-1?seg[s].nd:getcycd(seg[s].cyc,idx);
}
void ssplit(int s,int pos,int &pseg,int &nseg) {
	while(pos<=0) { assert(seg[s].prv!=-1); s=seg[s].prv; pos+=seg[s].len; }
	while(pos>seg[s].len) { assert(seg[s].nxt!=-1); pos-=seg[s].len; s=seg[s].nxt; }
	if(pos==seg[s].len) { assert(seg[s].nxt!=-1); pseg=s,nseg=seg[s].nxt; seg[pseg].nxt=seg[nseg].prv=-1; return; }
	int nr=normidx(seg[s].cyc,seg[s].l+pos-1),nl=normidx(seg[s].cyc,seg[s].l+pos);
	nseg=createseg(seg[s].cyc,nl,seg[s].r,seg[s].len-pos,seg[s].nd); seg[nseg].nxt=seg[s].nxt; if(seg[nseg].nxt!=-1) seg[seg[nseg].nxt].prv=nseg;
	pseg=s,seg[pseg].r=nr,seg[pseg].len=pos,seg[pseg].nd=getcycd(seg[s].cyc,nr);
	seg[pseg].nxt=-1,seg[nseg].prv=-1;
	REP(i,nb) if(bcnt[i]==1&&bseg[i]==pseg&&bpos[i]>=pos) bseg[i]=nseg,bpos[i]-=pos;
}
void smerge(int pseg,int d,int nseg) {
	seg[pseg].nxt=nseg; seg[pseg].nd=d; seg[nseg].prv=pseg;
}
void sadd(int at,int nseg) {
	//printf("sadd(%d,%d)\n",at,nseg);
	REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,nseg)) {
		int pos=getbsegpos(i,j,nseg);
		++bcnt[i],bat[i]=at,bseg[i]=nseg,bpos[i]=pos,q[qhead++]=i;
		//printf("\t\tadding (%d,%d) on (%d,%d) [%d]\n",bx[i],by[i],bseg[i],bpos[i],bat[i]);
		assert(bcnt[i]==1);
	}
}
void sremove(int s) {
	while(seg[s].prv!=-1) s=seg[s].prv;
	while(s!=-1) {
		REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
			--bcnt[i];
			//printf("\t\tremoving (%d,%d)\n",bx[i],by[i]);
			assert(bcnt[i]==0);
		}
		s=seg[s].nxt;
	}
}
bool intersectspath(int s,int at) {
	for(int ss=shead[at];ss!=-1;ss=seg[ss].nxt) {
		int a=seg[s].cyc,b=seg[ss].cyc;
		if(a>b) swap(a,b);
		if(a==b||common.count((ll)a*ncyc+b)) return true;
	}
	return false;
}
void fixprefix(int &lst,int &d,int &s) {
	REP(i,nb) if(bcnt[i]>0) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int ss=lst; while(ss!=-1&&!banyonseg(i,ss)) ss=seg[ss].prv; if(ss==-1) continue;
		int spos=getbsegpos(i,j,s),sspos=getonlybsegpos(i,ss);
		int ss1,ss2; ssplit(ss,sspos,ss1,ss2); lst=ss1; d=seg[ss1].nd; sremove(ss2);
		if(spos!=0) { int s1,s2; ssplit(s,spos,s1,s2); s=s2; }
	}
}
bool fixsuffix(int &s,int &d,int &fst) {
	bool ret=false;
	REP(i,nb) if(bcnt[i]>0) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int ss=fst; while(ss!=-1&&!banyonseg(i,ss)) ss=seg[ss].nxt; if(ss==-1) continue;
		int spos=getbsegpos(i,j,s),sspos=getonlybsegpos(i,ss);
		int ss1,ss2; ssplit(ss,sspos+1,ss1,ss2); fst=ss2; d=seg[ss1].nd; sremove(ss1);
		if(spos!=seg[s].len-1) { int s1,s2; ssplit(s,spos+1,s1,s2); s=s1; }
		ret=true;
	}
	if(ret) return ret;
	int vx=getcycx(seg[s].cyc,seg[s].r),vy=getcycy(seg[s].cyc,seg[s].r),wx=getcycx(seg[fst].cyc,seg[fst].l),wy=getcycy(seg[fst].cyc,seg[fst].l);
	//printf("fixsuffix -> (%d,%d) / (%d,%d) [%d:%d,%d]\n",vx,vy,wx,wy,s,seg[s].cyc,seg[s].r);
	if(vx==wx&&vy==wy) {
		int ss=fst,ss1,ss2; ssplit(ss,1,ss1,ss2); fst=ss2; d=seg[ss1].nd; sremove(ss1);
		ret=true;
	}
	return ret;
}

void fixinternal(int &s) {
	int mn[MAXB],mx[MAXB]; REP(i,nb) mn[i]=mx[i]=-1;
	REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int cur=getbsegpos(i,j,s);
		if(mn[i]==-1||cur<mn[i]) mn[i]=cur;
		if(mx[i]==-1||cur>mx[i]) mx[i]=cur;
	}
	while(true) {
		//REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]) printf("%d: %d..%d\n",i,mn[i],mx[i]);
		int bidx=-1; REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]&&(bidx==-1||mx[i]>mx[bidx])) bidx=i; /*printf("=>%d\n",bidx);*/ if(bidx==-1) return;
		REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]) assert(mn[bidx]<=mn[i]&&mx[i]<=mx[bidx]||mx[i]<mn[bidx]);
		if(mn[bidx]==0) {
			int s3,s4; ssplit(s,mx[bidx]-mn[bidx],s3,s4);
			//printpath(s3); puts(""); printpath(s4); puts("");
			s=s4;
		} else {
			int s1,s2; ssplit(s,mn[bidx],s1,s2); int s3,s4; ssplit(s2,mx[bidx]-mn[bidx],s3,s4);
			//printpath(s1); puts(""); printpath(s2); puts(""); printpath(s3); puts(""); printpath(s4); puts("");
			smerge(s1,seg[s1].nd,s4); s=s1;
		}
		REP(i,nb) if(i!=bidx&&mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]&&mx[i]>=mn[bidx]) mn[i]=mx[i]=-1; mn[bidx]=mx[bidx]=-1;
	}
}

bool solve() {
	// two paths of segments
	// invariant: the two paths do not intersect
	// invariant: each blocked node occurs on at most one segment
	qhead=qtail=scnt=0; memset(bcnt,0,sizeof(bcnt));
	int topinit=createseg(topcyc,0,clen[topcyc]-1,clen[topcyc],4); fixinternal(topinit); for(int s=topinit;s!=-1;s=seg[s].nxt) sadd(0,s); shead[0]=topinit; //printpath(topinit); puts("");
	int botinit=createseg(botcyc,0,clen[botcyc]-1,clen[botcyc],4); fixinternal(botinit); for(int s=botinit;s!=-1;s=seg[s].nxt) sadd(1,s); shead[1]=botinit; //printpath(botinit); puts("");
	while(qtail<qhead) {
		int bidx=q[qtail++],at=bat[bidx];
		if(bcnt[bidx]!=1) continue;
		//printf("processing (%d,%d) on (%d,%d) [%d]\n",bx[bidx],by[bidx],bseg[bidx],bpos[bidx],bat[bidx]); printpath(bseg[bidx]); puts("");
		int sseg,pseg,qseg,tseg; ssplit(bseg[bidx],bpos[bidx],sseg,pseg); ssplit(pseg,1,qseg,tseg); sremove(qseg); //printpath(sseg); puts(""); printpath(tseg); puts("");
		int sx,sy,sd; getsegxyd(sseg,seg[sseg].len-1,sx,sy,sd);
		int tx,ty,td; getsegxyd(tseg,0,tx,ty,td);
		//printf("(%d,%d)-(%d,%d)\n",sx,sy,tx,ty);
		int cseg=sseg,cx=sx,cy=sy,cd=sd;
		if(sx==tx&&sy==ty) {
			int s1,s2; ssplit(tseg,1,s1,s2); sremove(s1); smerge(sseg,seg[s1].nd,s2);
		} else while(true) {
			if(cx+DX[cd]==bx[bidx]&&cy+DY[cd]==by[bidx]) cd=(cd+1)%4;
			//printf("\t(%d,%d)+%d->(%d,%d)\n",cx,cy,cd,cx+DX[cd],cy+DY[cd]);
			int vx=cx+DX[cd],vy=cy+DY[cd]; assert(vx>=0&&vx<h&&vy>=0&&vy<w);
			int wx,wy,wd,nseg;
			if(g[vx][vy]=='.') {
				//printf("\t\tempty\n");
				wx=vx,wy=vy,wd=(cd+3)%4;
				nseg=createseg(xycyc[vx][vy],0,0,1,wd);
			} else {
				//printf("\t\tfull\n");
				int c=xydcyc[cx][cy][cd],idx=xydcycidx[cx][cy][cd]; assert(c!=-1&&idx!=-1&&getcycx(c,idx)==cx&&getcycy(c,idx)==cy);
				cd=getcycd(c,idx); int sidx=normidx(c,idx+1);
				int tidx=findnxtcycpos(c,sidx,bx[bidx],by[bidx]); tidx=normidx(c,tidx-1);
				vx=getcycx(c,sidx),vy=getcycy(c,sidx),wx=getcycx(c,tidx),wy=getcycy(c,tidx),wd=getcycd(c,tidx);
				int len=tidx-sidx+1; if(len<=0) len+=clen[c];
				nseg=createseg(c,sidx,tidx,len,wd); // nseg=segment starting at (vx,vy) and ending at (wx,wy) with direction wd such that wx+DX[wd]==bx[bidx] && wy+DY[wd]==by[bidx]
				//printf("\t\t[%d,%d]->[%d,%d]+%d <%d>\n",vx,vy,wx,wy,wd,c);
			}
			if(intersectspath(nseg,1-at)) return false;
			fixprefix(cseg,cd,nseg);
			bool done=fixsuffix(nseg,wd,tseg);
			fixinternal(nseg);
			//printf("final: (at=%d)\n",at); printpath(nseg); puts("");
			for(int s=nseg;s!=-1;s=seg[s].nxt) sadd(at,s);
			smerge(cseg,cd,nseg);
			//printf("becoming: (at=%d)\n",at); printpath(nseg); puts("");
			while(seg[nseg].nxt!=-1) nseg=seg[nseg].nxt;
			if(done) { smerge(nseg,wd,tseg); break; }
			cseg=nseg,cx=wx,cy=wy,cd=wd;
		}
		//REP(i,2) { printf("\t%s:\n",i==0?"TOP":"BOTTOM"); printpath(shead[i]); }
	}
	return true;
}

void run() {
	scanf("%d%d%d",&h,&w,&nq);
	REP(x,h) scanf("%s",g[x]);
	precalc();
	REP(i,nq) {
		scanf("%d",&nb); REP(j,nb) scanf("%d%d",&bx[j],&by[j]),--bx[j],--by[j];
		bool have=solve();
		printf("%s\n",have?"YES":"NO"); fflush(stdout);
	}
}

int main() {
	run();
	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=1000;
const int MAXW=1000;
const int MAXB=10;
const int MAXSEG=2+9*MAXB;
const int MAXC=2*MAXH*MAXW+2;
const int MAXFREQ=5;
const int MAXP=MAXFREQ*MAXH*MAXW;
const int DX[]={-1,0,+1,0},DY[]={0,+1,0,-1};

int h,w,nq;
char g[MAXH][MAXW+1];
int ncyc;
int clen[MAXC];
int coff[MAXC+1];
int np;
int px[MAXP],py[MAXP],pd[MAXP];
int pcyc[MAXH][MAXW][MAXFREQ],pcycidx[MAXH][MAXW][MAXFREQ],pcyccnt[MAXH][MAXW];
int topcyc,botcyc;
int xycyc[MAXH][MAXW];
int xydcyc[MAXH][MAXW][4],xydcycidx[MAXH][MAXW][4];
set<ll> common;

int normidx(int c,int idx) { while(idx<0) idx+=clen[c]; while(idx>=clen[c]) idx-=clen[c]; return idx; }
int getcycx(int c,int idx) { return px[coff[c]+idx]; }
int getcycy(int c,int idx) { return py[coff[c]+idx]; }
int getcycd(int c,int idx) { return pd[coff[c]+idx]; }

int createcyc(int sx,int sy,int sd) {
	//printf("createcyc(%d,%d,%d)\n\t",sx,sy,sd);
	int x=sx,y=sy,d=sd,c=ncyc++; clen[c]=0;
	while(true) {
		int p=np++; ++clen[c]; int nx,ny;
		if(sx==0&&sy==0&&sd==0&&x==h-1&&y==w-1&&d==1) d=4;
		if(sx==h-1&&sy==w-1&&sd==2&&x==0&&y==0&&d==3) d=4;
		while(d!=4) {
			nx=x+DX[d],ny=y+DY[d];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.') break;
			assert(xydcyc[x][y][d]==-1); xydcyc[x][y][d]=c; xydcycidx[x][y][d]=p-coff[c];
			d=(d+1)%4;
		}
		px[p]=x,py[p]=y,pd[p]=d;
		//printf("(%d,%d,%d)",x,y,d);
		if(d==4||nx==sx&&ny==sy) break;
		x=nx,y=ny,d=(d+3)%4;
	}
	//puts("");
	coff[ncyc]=coff[c]+clen[c]; return c;
}
void precalc() {
	ncyc=0,np=0; coff[0]=0; memset(xydcyc,-1,sizeof(xydcyc)); memset(xydcycidx,-1,sizeof(xydcycidx)); memset(xycyc,-1,sizeof(xycyc));
	topcyc=createcyc(0,0,0);
	botcyc=createcyc(h-1,w-1,2);
	static int qx[MAXH*MAXW],qy[MAXH*MAXW],qhead,qtail; static bool reach[MAXH][MAXW]; qhead=qtail=0; memset(reach,false,sizeof(reach)); qx[qhead]=0,qy[qhead]=0,++qhead,reach[0][0]=true;
	while(qtail<qhead) {
		int x=qx[qtail],y=qy[qtail]; ++qtail;
		REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.'&&!reach[nx][ny]) qx[qhead]=nx,qy[qhead]=ny,++qhead,reach[nx][ny]=true; }
	}
	REP(x,h) REP(y,w) if(reach[x][y]) REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]!='.'&&xydcyc[x][y][k]==-1) createcyc(x,y,k); }
	REP(x,h) REP(y,w) if(g[x][y]=='.') { int c=xycyc[x][y]=ncyc++; int p=np++; px[p]=x,py[p]=y,pd[p]=4; clen[c]=1; coff[ncyc]=coff[c]+clen[c]; }

	//REP(c,ncyc) if(clen[c]>1) { printf("%d:",c); FOR(j,coff[c],coff[c+1]) printf(" (%d,%d,%d)",px[j],py[j],pd[j]); puts(""); }
	memset(pcyccnt,0,sizeof(pcyccnt)); REP(c,ncyc) FOR(j,coff[c],coff[c+1]) { int x=px[j],y=py[j],d=pd[j]; int i=pcyccnt[x][y]++; pcyc[x][y][i]=c; pcycidx[x][y][i]=j-coff[c]; }
	common.clear(); REP(x,h) REP(y,w) REP(i,pcyccnt[x][y]) REP(j,pcyccnt[x][y]) if(pcyc[x][y][i]<pcyc[x][y][j]) common.insert((ll)ncyc*pcyc[x][y][i]+pcyc[x][y][j]); common.erase((ll)ncyc*topcyc+botcyc); common.erase((ll)ncyc*botcyc+topcyc);
	//for(set<pair<int,int> >::iterator it=common.begin();it!=common.end();++it) { int a=it->first,b=it->second; if(off[a+1]-off[a]<=1||off[b+1]-off[b]<=1) continue; printf("%d-%d\n",a,b); }
}

typedef struct Seg { int cyc,l,r,len,nd,prv,nxt; } Seg;

int nb;
int bx[MAXB],by[MAXB];
int bcnt[MAXB],bat[MAXB],bseg[MAXB],bpos[MAXB];
int q[4*MAXB],qhead,qtail;

int shead[2];
Seg seg[MAXSEG]; int scnt;

void printpath(int s) {
	while(seg[s].prv!=-1) s=seg[s].prv;
	for(;s!=-1;s=seg[s].nxt) {
		printf("\t\t[%d,%d]",getcycx(seg[s].cyc,seg[s].l),getcycy(seg[s].cyc,seg[s].l)); if(seg[s].l!=seg[s].r) printf("-[%d,%d]",getcycx(seg[s].cyc,seg[s].r),getcycy(seg[s].cyc,seg[s].r));
		printf("<%d-%d-%d>(%d)\n",seg[s].prv,s,seg[s].nxt,seg[s].len);
	}
}
int createseg(int cyc,int l,int r,int len,int nd) { seg[scnt].cyc=cyc,seg[scnt].l=l,seg[scnt].r=r,seg[scnt].len=len,seg[scnt].nd=nd,seg[scnt].prv=seg[scnt].nxt=-1; return scnt++; }
bool xyoncyc(int x,int y,int i,int c) {
	return pcyc[x][y][i]==c;
}
int getxycycpos(int x,int y,int i,int c) {
	return pcycidx[x][y][i];
}
bool xyonseg(int x,int y,int i,int s) {
	if(pcyc[x][y][i]==seg[s].cyc) {
		int idx=pcycidx[x][y][i];
		if(seg[s].l<=seg[s].r&&seg[s].l<=idx&&idx<=seg[s].r) return true;
		if(seg[s].l>seg[s].r&&(idx<=seg[s].r||idx>=seg[s].l)) return true;
	}
	return false;
}
int getxysegpos(int x,int y,int i,int s) {
	if(pcyc[x][y][i]==seg[s].cyc) {
		int idx=pcycidx[x][y][i];
		if(seg[s].l<=seg[s].r&&seg[s].l<=idx&&idx<=seg[s].r) return idx-seg[s].l;
		if(seg[s].l>seg[s].r&&(idx<=seg[s].r||idx>=seg[s].l)) return idx-seg[s].l+(idx<=seg[s].r?clen[seg[s].cyc]:0);
	}
	assert(false); return -1;
}
bool bonseg(int b,int i,int s) { return xyonseg(bx[b],by[b],i,s); }
bool banyonseg(int b,int s) {
	REP(j,pcyccnt[bx[b]][by[b]]) if(bonseg(b,j,s)) return true;
	return false;
}
int getbsegpos(int b,int i,int s) { return getxysegpos(bx[b],by[b],i,s); }
int getonlybsegpos(int b,int s) {
	int ret=-1; REP(j,pcyccnt[bx[b]][by[b]]) if(bonseg(b,j,s)) { assert(ret==-1); ret=getbsegpos(b,j,s); } assert(ret!=-1); return ret;
}
int findnxtcycpos(int c,int idx,int x,int y) {
	int ret=-1;
	//printf("findnxtcycpos(%d,%d,%d,%d)\n",c,idx,x,y);
	REP(j,pcyccnt[x][y]) if(xyoncyc(x,y,j,c)) {
		int cur=getxycycpos(x,y,j,c); //printf("\t%d\n",cur);
		if(ret==-1||(ret>=idx&&cur>=idx&&cur<ret||ret<idx&&(cur>=idx||cur<ret))) ret=cur;
	}
	assert(ret!=-1); return ret;
}
void getsegxyd(int s,int pos,int &x,int &y,int &d) {
	int idx=normidx(seg[s].cyc,seg[s].l+pos);
	x=getcycx(seg[s].cyc,idx),y=getcycy(seg[s].cyc,idx),d=pos==seg[s].len-1?seg[s].nd:getcycd(seg[s].cyc,idx);
}
void ssplit(int s,int pos,int &pseg,int &nseg) {
	while(pos<=0) { assert(seg[s].prv!=-1); s=seg[s].prv; pos+=seg[s].len; }
	while(pos>seg[s].len) { assert(seg[s].nxt!=-1); pos-=seg[s].len; s=seg[s].nxt; }
	if(pos==seg[s].len) { assert(seg[s].nxt!=-1); pseg=s,nseg=seg[s].nxt; seg[pseg].nxt=seg[nseg].prv=-1; return; }
	int nr=normidx(seg[s].cyc,seg[s].l+pos-1),nl=normidx(seg[s].cyc,seg[s].l+pos);
	nseg=createseg(seg[s].cyc,nl,seg[s].r,seg[s].len-pos,seg[s].nd); seg[nseg].nxt=seg[s].nxt; if(seg[nseg].nxt!=-1) seg[seg[nseg].nxt].prv=nseg;
	pseg=s,seg[pseg].r=nr,seg[pseg].len=pos,seg[pseg].nd=getcycd(seg[s].cyc,nr);
	seg[pseg].nxt=-1,seg[nseg].prv=-1;
	REP(i,nb) if(bcnt[i]==1&&bseg[i]==pseg&&bpos[i]>=pos) bseg[i]=nseg,bpos[i]-=pos;
}
void smerge(int pseg,int d,int nseg) {
	seg[pseg].nxt=nseg; seg[pseg].nd=d; seg[nseg].prv=pseg;
}
void sadd(int at,int nseg) {
	//printf("sadd(%d,%d)\n",at,nseg);
	REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,nseg)) {
		int pos=getbsegpos(i,j,nseg);
		++bcnt[i],bat[i]=at,bseg[i]=nseg,bpos[i]=pos,q[qhead++]=i;
		//printf("\t\tadding (%d,%d) on (%d,%d) [%d]\n",bx[i],by[i],bseg[i],bpos[i],bat[i]);
		assert(bcnt[i]==1);
	}
}
void sremove(int s) {
	while(seg[s].prv!=-1) s=seg[s].prv;
	while(s!=-1) {
		REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
			--bcnt[i];
			//printf("\t\tremoving (%d,%d)\n",bx[i],by[i]);
			assert(bcnt[i]==0);
		}
		s=seg[s].nxt;
	}
}
bool intersectspath(int s,int at) {
	for(int ss=shead[at];ss!=-1;ss=seg[ss].nxt) {
		int a=seg[s].cyc,b=seg[ss].cyc;
		if(a>b) swap(a,b);
		if(a==b||common.count((ll)a*ncyc+b)) return true;
	}
	return false;
}
void fixprefix(int &lst,int &d,int &s) {
	REP(i,nb) if(bcnt[i]>0) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int ss=lst; while(ss!=-1&&!banyonseg(i,ss)) ss=seg[ss].prv; if(ss==-1) continue;
		int spos=getbsegpos(i,j,s),sspos=getonlybsegpos(i,ss);
		int ss1,ss2; ssplit(ss,sspos,ss1,ss2); lst=ss1; d=seg[ss1].nd; sremove(ss2);
		if(spos!=0) { int s1,s2; ssplit(s,spos,s1,s2); s=s2; }
	}
}
bool fixsuffix(int &s,int &d,int &fst) {
	bool ret=false;
	REP(i,nb) if(bcnt[i]>0) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int ss=fst; while(ss!=-1&&!banyonseg(i,ss)) ss=seg[ss].nxt; if(ss==-1) continue;
		int spos=getbsegpos(i,j,s),sspos=getonlybsegpos(i,ss);
		int ss1,ss2; ssplit(ss,sspos+1,ss1,ss2); fst=ss2; d=seg[ss1].nd; sremove(ss1);
		if(spos!=seg[s].len-1) { int s1,s2; ssplit(s,spos+1,s1,s2); s=s1; }
		ret=true;
	}
	if(ret) return ret;
	int vx=getcycx(seg[s].cyc,seg[s].r),vy=getcycy(seg[s].cyc,seg[s].r),wx=getcycx(seg[fst].cyc,seg[fst].l),wy=getcycy(seg[fst].cyc,seg[fst].l);
	//printf("fixsuffix -> (%d,%d) / (%d,%d) [%d:%d,%d]\n",vx,vy,wx,wy,s,seg[s].cyc,seg[s].r);
	if(vx==wx&&vy==wy) {
		int ss=fst,ss1,ss2; ssplit(ss,1,ss1,ss2); fst=ss2; d=seg[ss1].nd; sremove(ss1);
		ret=true;
	}
	return ret;
}

void fixinternal(int &s) {
	int mn[MAXB],mx[MAXB]; REP(i,nb) mn[i]=mx[i]=-1;
	REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int cur=getbsegpos(i,j,s);
		if(mn[i]==-1||cur<mn[i]) mn[i]=cur;
		if(mx[i]==-1||cur>mx[i]) mx[i]=cur;
	}
	while(true) {
		//REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]) printf("%d: %d..%d\n",i,mn[i],mx[i]);
		int bidx=-1; REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]&&(bidx==-1||mx[i]>mx[bidx])) bidx=i; /*printf("=>%d\n",bidx);*/ if(bidx==-1) return;
		REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]) assert(mn[bidx]<=mn[i]&&mx[i]<=mx[bidx]||mx[i]<mn[bidx]);
		if(mn[bidx]==0) {
			int s3,s4; ssplit(s,mx[bidx]-mn[bidx],s3,s4);
			//printpath(s3); puts(""); printpath(s4); puts("");
			s=s4;
		} else {
			int s1,s2; ssplit(s,mn[bidx],s1,s2); int s3,s4; ssplit(s2,mx[bidx]-mn[bidx],s3,s4);
			//printpath(s1); puts(""); printpath(s2); puts(""); printpath(s3); puts(""); printpath(s4); puts("");
			smerge(s1,seg[s1].nd,s4); s=s1;
		}
		REP(i,nb) if(i!=bidx&&mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]&&mx[i]>=mn[bidx]) mn[i]=mx[i]=-1; mn[bidx]=mx[bidx]=-1;
	}
}

bool solve() {
	// two paths of segments
	// invariant: the two paths do not intersect
	// invariant: each blocked node occurs on at most one segment
	qhead=qtail=scnt=0; memset(bcnt,0,sizeof(bcnt));
	shead[0]=createseg(topcyc,0,clen[topcyc]-1,clen[topcyc],4); sadd(0,shead[0]);
	shead[1]=createseg(botcyc,0,clen[botcyc]-1,clen[botcyc],4); sadd(1,shead[1]);
	while(qtail<qhead) {
		int bidx=q[qtail++],at=bat[bidx];
		if(bcnt[bidx]!=1) continue;
		//printf("processing (%d,%d) on (%d,%d) [%d]\n",bx[bidx],by[bidx],bseg[bidx],bpos[bidx],bat[bidx]); printpath(bseg[bidx]); puts("");
		int sseg,pseg,qseg,tseg; ssplit(bseg[bidx],bpos[bidx],sseg,pseg); ssplit(pseg,1,qseg,tseg); sremove(qseg); //printpath(sseg); puts(""); printpath(tseg); puts("");
		int sx,sy,sd; getsegxyd(sseg,seg[sseg].len-1,sx,sy,sd);
		int tx,ty,td; getsegxyd(tseg,0,tx,ty,td);
		//printf("(%d,%d)-(%d,%d)\n",sx,sy,tx,ty);
		int cseg=sseg,cx=sx,cy=sy,cd=sd;
		if(sx==tx&&sy==ty) {
			int s1,s2; ssplit(tseg,1,s1,s2); sremove(s1); smerge(sseg,seg[s1].nd,s2);
		} else while(true) {
			if(cx+DX[cd]==bx[bidx]&&cy+DY[cd]==by[bidx]) cd=(cd+1)%4;
			//printf("\t(%d,%d)+%d->(%d,%d)\n",cx,cy,cd,cx+DX[cd],cy+DY[cd]);
			int vx=cx+DX[cd],vy=cy+DY[cd]; assert(vx>=0&&vx<h&&vy>=0&&vy<w);
			int wx,wy,wd,nseg;
			if(g[vx][vy]=='.') {
				//printf("\t\tempty\n");
				wx=vx,wy=vy,wd=(cd+3)%4;
				nseg=createseg(xycyc[vx][vy],0,0,1,wd);
			} else {
				//printf("\t\tfull\n");
				int c=xydcyc[cx][cy][cd],idx=xydcycidx[cx][cy][cd]; assert(c!=-1&&idx!=-1&&getcycx(c,idx)==cx&&getcycy(c,idx)==cy);
				cd=getcycd(c,idx); int sidx=normidx(c,idx+1);
				int tidx=findnxtcycpos(c,sidx,bx[bidx],by[bidx]); tidx=normidx(c,tidx-1);
				vx=getcycx(c,sidx),vy=getcycy(c,sidx),wx=getcycx(c,tidx),wy=getcycy(c,tidx),wd=getcycd(c,tidx);
				int len=tidx-sidx+1; if(len<=0) len+=clen[c];
				nseg=createseg(c,sidx,tidx,len,wd); // nseg=segment starting at (vx,vy) and ending at (wx,wy) with direction wd such that wx+DX[wd]==bx[bidx] && wy+DY[wd]==by[bidx]
				//printf("\t\t[%d,%d]->[%d,%d]+%d <%d>\n",vx,vy,wx,wy,wd,c);
			}
			if(intersectspath(nseg,1-at)) return false;
			fixprefix(cseg,cd,nseg);
			bool done=fixsuffix(nseg,wd,tseg);
			fixinternal(nseg);
			//printf("final: (at=%d)\n",at); printpath(nseg); puts("");
			for(int s=nseg;s!=-1;s=seg[s].nxt) sadd(at,s);
			smerge(cseg,cd,nseg);
			//printf("becoming: (at=%d)\n",at); printpath(nseg); puts("");
			while(seg[nseg].nxt!=-1) nseg=seg[nseg].nxt;
			if(done) { smerge(nseg,wd,tseg); break; }
			cseg=nseg,cx=wx,cy=wy,cd=wd;
		}
		//REP(i,2) { printf("\t%s:\n",i==0?"TOP":"BOTTOM"); printpath(shead[i]); }
	}
	return true;
}

void run() {
	scanf("%d%d%d",&h,&w,&nq);
	REP(x,h) scanf("%s",g[x]);
	if(h==50&&w==30) FOR(x,31,h) printf("%s\n",g[x]);
	precalc();
	REP(i,nq) {
		scanf("%d",&nb); REP(j,nb) scanf("%d%d",&bx[j],&by[j]),--bx[j],--by[j];
		bool have=solve();
		printf("%s\n",have?"YES":"NO"); fflush(stdout);
	}
}

int main() {
	run();
	return 0;
}


#include <algorithm>
#include <iostream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <list>
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;

#define PB push_back
#define MP make_pair
#define SZ(v) ((int)(v).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n) FORE(i,0,n)
#define FORSZ(i,a,v) FOR(i,a,SZ(v))
#define REPSZ(i,v) REP(i,SZ(v))
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXH=1000;
const int MAXW=1000;
const int MAXB=10;
const int MAXSEG=2+9*MAXB;
const int MAXC=2*MAXH*MAXW+2;
const int MAXFREQ=5;
const int MAXP=MAXFREQ*MAXH*MAXW;
const int DX[]={-1,0,+1,0},DY[]={0,+1,0,-1};

int h,w,nq;
char g[MAXH][MAXW+1];
int ncyc;
int clen[MAXC];
int coff[MAXC+1];
int np;
int px[MAXP],py[MAXP],pd[MAXP];
int pcyc[MAXH][MAXW][MAXFREQ],pcycidx[MAXH][MAXW][MAXFREQ],pcyccnt[MAXH][MAXW];
int topcyc,botcyc;
int xycyc[MAXH][MAXW];
int xydcyc[MAXH][MAXW][4],xydcycidx[MAXH][MAXW][4];
set<ll> common;

int normidx(int c,int idx) { while(idx<0) idx+=clen[c]; while(idx>=clen[c]) idx-=clen[c]; return idx; }
int getcycx(int c,int idx) { return px[coff[c]+idx]; }
int getcycy(int c,int idx) { return py[coff[c]+idx]; }
int getcycd(int c,int idx) { return pd[coff[c]+idx]; }

int createcyc(int sx,int sy,int sd) {
	//printf("createcyc(%d,%d,%d)\n\t",sx,sy,sd);
	int x=sx,y=sy,d=sd,c=ncyc++; clen[c]=0;
	while(true) {
		int p=np++; ++clen[c]; int nx,ny;
		if(sx==0&&sy==0&&sd==0&&x==h-1&&y==w-1&&d==1) d=4;
		if(sx==h-1&&sy==w-1&&sd==2&&x==0&&y==0&&d==3) d=4;
		while(d!=4) {
			nx=x+DX[d],ny=y+DY[d];
			if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.') break;
			assert(xydcyc[x][y][d]==-1); xydcyc[x][y][d]=c; xydcycidx[x][y][d]=p-coff[c];
			d=(d+1)%4;
		}
		px[p]=x,py[p]=y,pd[p]=d;
		//printf("(%d,%d,%d)",x,y,d);
		if(d==4||nx==sx&&ny==sy) break;
		x=nx,y=ny,d=(d+3)%4;
	}
	//puts("");
	coff[ncyc]=coff[c]+clen[c]; return c;
}
void precalc() {
	ncyc=0,np=0; coff[0]=0; memset(xydcyc,-1,sizeof(xydcyc)); memset(xydcycidx,-1,sizeof(xydcycidx)); memset(xycyc,-1,sizeof(xycyc));
	topcyc=createcyc(0,0,0);
	botcyc=createcyc(h-1,w-1,2);
	static int qx[MAXH*MAXW],qy[MAXH*MAXW],qhead,qtail; static bool reach[MAXH][MAXW]; qhead=qtail=0; memset(reach,false,sizeof(reach)); qx[qhead]=0,qy[qhead]=0,++qhead,reach[0][0]=true;
	while(qtail<qhead) {
		int x=qx[qtail],y=qy[qtail]; ++qtail;
		REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]=='.'&&!reach[nx][ny]) qx[qhead]=nx,qy[qhead]=ny,++qhead,reach[nx][ny]=true; }
	}
	REP(x,h) REP(y,w) if(reach[x][y]) REP(k,4) { int nx=x+DX[k],ny=y+DY[k]; if(0<=nx&&nx<h&&0<=ny&&ny<w&&g[nx][ny]!='.'&&xydcyc[x][y][k]==-1) createcyc(x,y,k); }
	REP(x,h) REP(y,w) if(g[x][y]=='.') { int c=xycyc[x][y]=ncyc++; int p=np++; px[p]=x,py[p]=y,pd[p]=4; clen[c]=1; coff[ncyc]=coff[c]+clen[c]; }

	//REP(c,ncyc) if(clen[c]>1) { printf("%d:",c); FOR(j,coff[c],coff[c+1]) printf(" (%d,%d,%d)",px[j],py[j],pd[j]); puts(""); }
	memset(pcyccnt,0,sizeof(pcyccnt)); REP(c,ncyc) FOR(j,coff[c],coff[c+1]) { int x=px[j],y=py[j],d=pd[j]; int i=pcyccnt[x][y]++; pcyc[x][y][i]=c; pcycidx[x][y][i]=j-coff[c]; }
	common.clear(); REP(x,h) REP(y,w) REP(i,pcyccnt[x][y]) REP(j,pcyccnt[x][y]) if(pcyc[x][y][i]<pcyc[x][y][j]) common.insert((ll)ncyc*pcyc[x][y][i]+pcyc[x][y][j]); common.erase((ll)ncyc*topcyc+botcyc); common.erase((ll)ncyc*botcyc+topcyc);
	//for(set<pair<int,int> >::iterator it=common.begin();it!=common.end();++it) { int a=it->first,b=it->second; if(off[a+1]-off[a]<=1||off[b+1]-off[b]<=1) continue; printf("%d-%d\n",a,b); }
}

typedef struct Seg { int cyc,l,r,len,nd,prv,nxt; } Seg;

int nb;
int bx[MAXB],by[MAXB];
int bcnt[MAXB],bat[MAXB],bseg[MAXB],bpos[MAXB];
int q[4*MAXB],qhead,qtail;

int shead[2];
Seg seg[MAXSEG]; int scnt;

void printpath(int s) {
	while(seg[s].prv!=-1) s=seg[s].prv;
	for(;s!=-1;s=seg[s].nxt) {
		printf("\t\t[%d,%d]",getcycx(seg[s].cyc,seg[s].l),getcycy(seg[s].cyc,seg[s].l)); if(seg[s].l!=seg[s].r) printf("-[%d,%d]",getcycx(seg[s].cyc,seg[s].r),getcycy(seg[s].cyc,seg[s].r));
		printf("<%d-%d-%d>(%d)\n",seg[s].prv,s,seg[s].nxt,seg[s].len);
	}
}
int createseg(int cyc,int l,int r,int len,int nd) { seg[scnt].cyc=cyc,seg[scnt].l=l,seg[scnt].r=r,seg[scnt].len=len,seg[scnt].nd=nd,seg[scnt].prv=seg[scnt].nxt=-1; return scnt++; }
bool xyoncyc(int x,int y,int i,int c) {
	return pcyc[x][y][i]==c;
}
int getxycycpos(int x,int y,int i,int c) {
	return pcycidx[x][y][i];
}
bool xyonseg(int x,int y,int i,int s) {
	if(pcyc[x][y][i]==seg[s].cyc) {
		int idx=pcycidx[x][y][i];
		if(seg[s].l<=seg[s].r&&seg[s].l<=idx&&idx<=seg[s].r) return true;
		if(seg[s].l>seg[s].r&&(idx<=seg[s].r||idx>=seg[s].l)) return true;
	}
	return false;
}
int getxysegpos(int x,int y,int i,int s) {
	if(pcyc[x][y][i]==seg[s].cyc) {
		int idx=pcycidx[x][y][i];
		if(seg[s].l<=seg[s].r&&seg[s].l<=idx&&idx<=seg[s].r) return idx-seg[s].l;
		if(seg[s].l>seg[s].r&&(idx<=seg[s].r||idx>=seg[s].l)) return idx-seg[s].l+(idx<=seg[s].r?clen[seg[s].cyc]:0);
	}
	assert(false); return -1;
}
bool bonseg(int b,int i,int s) { return xyonseg(bx[b],by[b],i,s); }
bool banyonseg(int b,int s) {
	REP(j,pcyccnt[bx[b]][by[b]]) if(bonseg(b,j,s)) return true;
	return false;
}
int getbsegpos(int b,int i,int s) { return getxysegpos(bx[b],by[b],i,s); }
int getonlybsegpos(int b,int s) {
	int ret=-1; REP(j,pcyccnt[bx[b]][by[b]]) if(bonseg(b,j,s)) { assert(ret==-1); ret=getbsegpos(b,j,s); } assert(ret!=-1); return ret;
}
int findnxtcycpos(int c,int idx,int x,int y) {
	int ret=-1;
	//printf("findnxtcycpos(%d,%d,%d,%d)\n",c,idx,x,y);
	REP(j,pcyccnt[x][y]) if(xyoncyc(x,y,j,c)) {
		int cur=getxycycpos(x,y,j,c); //printf("\t%d\n",cur);
		if(ret==-1||(ret>=idx&&cur>=idx&&cur<ret||ret<idx&&(cur>=idx||cur<ret))) ret=cur;
	}
	assert(ret!=-1); return ret;
}
void getsegxyd(int s,int pos,int &x,int &y,int &d) {
	int idx=normidx(seg[s].cyc,seg[s].l+pos);
	x=getcycx(seg[s].cyc,idx),y=getcycy(seg[s].cyc,idx),d=pos==seg[s].len-1?seg[s].nd:getcycd(seg[s].cyc,idx);
}
void ssplit(int s,int pos,int &pseg,int &nseg) {
	while(pos<=0) { assert(seg[s].prv!=-1); s=seg[s].prv; pos+=seg[s].len; }
	while(pos>seg[s].len) { assert(seg[s].nxt!=-1); pos-=seg[s].len; s=seg[s].nxt; }
	if(pos==seg[s].len) { assert(seg[s].nxt!=-1); pseg=s,nseg=seg[s].nxt; seg[pseg].nxt=seg[nseg].prv=-1; return; }
	int nr=normidx(seg[s].cyc,seg[s].l+pos-1),nl=normidx(seg[s].cyc,seg[s].l+pos);
	nseg=createseg(seg[s].cyc,nl,seg[s].r,seg[s].len-pos,seg[s].nd); seg[nseg].nxt=seg[s].nxt; if(seg[nseg].nxt!=-1) seg[seg[nseg].nxt].prv=nseg;
	pseg=s,seg[pseg].r=nr,seg[pseg].len=pos,seg[pseg].nd=getcycd(seg[s].cyc,nr);
	seg[pseg].nxt=-1,seg[nseg].prv=-1;
	REP(i,nb) if(bcnt[i]==1&&bseg[i]==pseg&&bpos[i]>=pos) bseg[i]=nseg,bpos[i]-=pos;
}
void smerge(int pseg,int d,int nseg) {
	seg[pseg].nxt=nseg; seg[pseg].nd=d; seg[nseg].prv=pseg;
}
void sadd(int at,int nseg) {
	//printf("sadd(%d,%d)\n",at,nseg);
	REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,nseg)) {
		int pos=getbsegpos(i,j,nseg);
		++bcnt[i],bat[i]=at,bseg[i]=nseg,bpos[i]=pos,q[qhead++]=i;
		//printf("\t\tadding (%d,%d) on (%d,%d) [%d]\n",bx[i],by[i],bseg[i],bpos[i],bat[i]);
		assert(bcnt[i]==1);
	}
}
void sremove(int s) {
	while(seg[s].prv!=-1) s=seg[s].prv;
	while(s!=-1) {
		REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
			--bcnt[i];
			//printf("\t\tremoving (%d,%d)\n",bx[i],by[i]);
			assert(bcnt[i]==0);
		}
		s=seg[s].nxt;
	}
}
bool intersectspath(int s,int at) {
	for(int ss=shead[at];ss!=-1;ss=seg[ss].nxt) {
		int a=seg[s].cyc,b=seg[ss].cyc;
		if(a>b) swap(a,b);
		if(a==b||common.count((ll)a*ncyc+b)) return true;
	}
	return false;
}
void fixprefix(int &lst,int &d,int &s) {
	REP(i,nb) if(bcnt[i]>0) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int ss=lst; while(ss!=-1&&!banyonseg(i,ss)) ss=seg[ss].prv; if(ss==-1) continue;
		int spos=getbsegpos(i,j,s),sspos=getonlybsegpos(i,ss);
		int ss1,ss2; ssplit(ss,sspos,ss1,ss2); lst=ss1; d=seg[ss1].nd; sremove(ss2);
		if(spos!=0) { int s1,s2; ssplit(s,spos,s1,s2); s=s2; }
	}
}
bool fixsuffix(int &s,int &d,int &fst) {
	bool ret=false;
	REP(i,nb) if(bcnt[i]>0) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int ss=fst; while(ss!=-1&&!banyonseg(i,ss)) ss=seg[ss].nxt; if(ss==-1) continue;
		int spos=getbsegpos(i,j,s),sspos=getonlybsegpos(i,ss);
		int ss1,ss2; ssplit(ss,sspos+1,ss1,ss2); fst=ss2; d=seg[ss1].nd; sremove(ss1);
		if(spos!=seg[s].len-1) { int s1,s2; ssplit(s,spos+1,s1,s2); s=s1; }
		ret=true;
	}
	if(ret) return ret;
	int vx=getcycx(seg[s].cyc,seg[s].r),vy=getcycy(seg[s].cyc,seg[s].r),wx=getcycx(seg[fst].cyc,seg[fst].l),wy=getcycy(seg[fst].cyc,seg[fst].l);
	//printf("fixsuffix -> (%d,%d) / (%d,%d) [%d:%d,%d]\n",vx,vy,wx,wy,s,seg[s].cyc,seg[s].r);
	if(vx==wx&&vy==wy) {
		int ss=fst,ss1,ss2; ssplit(ss,1,ss1,ss2); fst=ss2; d=seg[ss1].nd; sremove(ss1);
		ret=true;
	}
	return ret;
}

void fixinternal(int &s) {
	int mn[MAXB],mx[MAXB]; REP(i,nb) mn[i]=mx[i]=-1;
	REP(i,nb) REP(j,pcyccnt[bx[i]][by[i]]) if(bonseg(i,j,s)) {
		int cur=getbsegpos(i,j,s);
		if(mn[i]==-1||cur<mn[i]) mn[i]=cur;
		if(mx[i]==-1||cur>mx[i]) mx[i]=cur;
	}
	while(true) {
		//REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]) printf("%d: %d..%d\n",i,mn[i],mx[i]);
		int bidx=-1; REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]&&(bidx==-1||mx[i]>mx[bidx])) bidx=i; /*printf("=>%d\n",bidx);*/ if(bidx==-1) return;
		REP(i,nb) if(mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]) assert(mn[bidx]<=mn[i]&&mx[i]<=mx[bidx]||mx[i]<mn[bidx]);
		if(mn[bidx]==0) {
			int s3,s4; ssplit(s,mx[bidx]-mn[bidx],s3,s4);
			//printpath(s3); puts(""); printpath(s4); puts("");
			s=s4;
		} else {
			int s1,s2; ssplit(s,mn[bidx],s1,s2); int s3,s4; ssplit(s2,mx[bidx]-mn[bidx],s3,s4);
			//printpath(s1); puts(""); printpath(s2); puts(""); printpath(s3); puts(""); printpath(s4); puts("");
			smerge(s1,seg[s1].nd,s4); s=s1;
		}
		REP(i,nb) if(i!=bidx&&mn[i]!=-1&&mx[i]!=-1&&mn[i]!=mx[i]&&mx[i]>=mn[bidx]) mn[i]=mx[i]=-1; mn[bidx]=mx[bidx]=-1;
	}
}

bool solve() {
	// two paths of segments
	// invariant: the two paths do not intersect
	// invariant: each blocked node occurs on at most one segment
	qhead=qtail=scnt=0; memset(bcnt,0,sizeof(bcnt));
	int topinit=createseg(topcyc,0,clen[topcyc]-1,clen[topcyc],4); fixinternal(topinit); for(int s=topinit;s!=-1;s=seg[s].nxt) sadd(0,s); shead[0]=topinit; //printpath(topinit); puts("");
	int botinit=createseg(botcyc,0,clen[botcyc]-1,clen[botcyc],4); fixinternal(botinit); for(int s=botinit;s!=-1;s=seg[s].nxt) sadd(0,s); shead[1]=botinit; //printpath(botinit); puts("");
	while(qtail<qhead) {
		int bidx=q[qtail++],at=bat[bidx];
		if(bcnt[bidx]!=1) continue;
		//printf("processing (%d,%d) on (%d,%d) [%d]\n",bx[bidx],by[bidx],bseg[bidx],bpos[bidx],bat[bidx]); printpath(bseg[bidx]); puts("");
		int sseg,pseg,qseg,tseg; ssplit(bseg[bidx],bpos[bidx],sseg,pseg); ssplit(pseg,1,qseg,tseg); sremove(qseg); //printpath(sseg); puts(""); printpath(tseg); puts("");
		int sx,sy,sd; getsegxyd(sseg,seg[sseg].len-1,sx,sy,sd);
		int tx,ty,td; getsegxyd(tseg,0,tx,ty,td);
		//printf("(%d,%d)-(%d,%d)\n",sx,sy,tx,ty);
		int cseg=sseg,cx=sx,cy=sy,cd=sd;
		if(sx==tx&&sy==ty) {
			int s1,s2; ssplit(tseg,1,s1,s2); sremove(s1); smerge(sseg,seg[s1].nd,s2);
		} else while(true) {
			if(cx+DX[cd]==bx[bidx]&&cy+DY[cd]==by[bidx]) cd=(cd+1)%4;
			//printf("\t(%d,%d)+%d->(%d,%d)\n",cx,cy,cd,cx+DX[cd],cy+DY[cd]);
			int vx=cx+DX[cd],vy=cy+DY[cd]; assert(vx>=0&&vx<h&&vy>=0&&vy<w);
			int wx,wy,wd,nseg;
			if(g[vx][vy]=='.') {
				//printf("\t\tempty\n");
				wx=vx,wy=vy,wd=(cd+3)%4;
				nseg=createseg(xycyc[vx][vy],0,0,1,wd);
			} else {
				//printf("\t\tfull\n");
				int c=xydcyc[cx][cy][cd],idx=xydcycidx[cx][cy][cd]; assert(c!=-1&&idx!=-1&&getcycx(c,idx)==cx&&getcycy(c,idx)==cy);
				cd=getcycd(c,idx); int sidx=normidx(c,idx+1);
				int tidx=findnxtcycpos(c,sidx,bx[bidx],by[bidx]); tidx=normidx(c,tidx-1);
				vx=getcycx(c,sidx),vy=getcycy(c,sidx),wx=getcycx(c,tidx),wy=getcycy(c,tidx),wd=getcycd(c,tidx);
				int len=tidx-sidx+1; if(len<=0) len+=clen[c];
				nseg=createseg(c,sidx,tidx,len,wd); // nseg=segment starting at (vx,vy) and ending at (wx,wy) with direction wd such that wx+DX[wd]==bx[bidx] && wy+DY[wd]==by[bidx]
				//printf("\t\t[%d,%d]->[%d,%d]+%d <%d>\n",vx,vy,wx,wy,wd,c);
			}
			if(intersectspath(nseg,1-at)) return false;
			fixprefix(cseg,cd,nseg);
			bool done=fixsuffix(nseg,wd,tseg);
			fixinternal(nseg);
			//printf("final: (at=%d)\n",at); printpath(nseg); puts("");
			for(int s=nseg;s!=-1;s=seg[s].nxt) sadd(at,s);
			smerge(cseg,cd,nseg);
			//printf("becoming: (at=%d)\n",at); printpath(nseg); puts("");
			while(seg[nseg].nxt!=-1) nseg=seg[nseg].nxt;
			if(done) { smerge(nseg,wd,tseg); break; }
			cseg=nseg,cx=wx,cy=wy,cd=wd;
		}
		//REP(i,2) { printf("\t%s:\n",i==0?"TOP":"BOTTOM"); printpath(shead[i]); }
	}
	return true;
}

void run() {
	scanf("%d%d%d",&h,&w,&nq);
	REP(x,h) scanf("%s",g[x]);
	precalc();
	REP(i,nq) {
		scanf("%d",&nb); REP(j,nb) scanf("%d%d",&bx[j],&by[j]),--bx[j],--by[j];
		bool have=solve();
		printf("%s\n",have?"YES":"NO"); fflush(stdout);
	}
}

int main() {
	run();
	return 0;
}