#include <iostream>

using namespace std;

string maps[2][30];
int cnt[2];
int x[2000], y[2000];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int ncase; cin >> ncase;
	for (int csnum = 1; csnum <= ncase; csnum++) {
		int w, h, n; cin >> w >> h >> n;
		for (int s = 0; s < 2; s++) {
			cnt[s] = 0;
			for (int i = 0; i < h; i++) {
				cin >> maps[s][i];
				for (int j = 0; j < w; j++) {
					if (maps[s][i][j] == '#') {
						cnt[s]++;
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			cin >> x[i] >> y[i];
		}

		int p = 0;
		int completedTurns = 0;
		bool ended = false;
		if (cnt[0] == 0 || cnt[1] == 0) ended = true;
		for (int i = 0; i < n && (!ended || completedTurns%2 == 1); i++) {
			int r = h-1-y[i], c = x[i];
			int t = (p+1)%2;
			if (maps[t][r][c] == '#') {
				maps[t][r][c] = '_';
				cnt[t]--;
				if (cnt[t] == 0) {
					ended = true;
					p = t;
					completedTurns++;
				}
			} else {
				p = t;
				completedTurns++;
			}
		}

		bool d[2] = {cnt[0]==0, cnt[1]==0};
		if (d[0] == d[1]) {
			cout << "draw" << endl;
		} else if (d[1]) {
			cout << "player one wins" << endl;
		} else {
			cout << "player two wins" << endl;
		}
	}
}