#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



int H, W;
string M[105];
int dx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dy[8] = { -1,-1,0,1,1,1,0,-1 };
//-----------------------------------------------------------------
int mod = 1000000007;
int rnd[20101];
void pre() {
	mt19937 mt(time(NULL));
	uniform_int_distribution<int> uni(0, mod - 1);
	rep(i, 0, H * W) rnd[i] = uni(mt);
}
//-----------------------------------------------------------------
int P[105][105];
int N;
void dfs2(int x, int y, int c) {
	P[y][x] = c;
	rep(i, 0, 8) {
		int yy = y + dy[i];
		int xx = x + dx[i];
		if (yy < 0 || H <= yy) continue;
		if (xx < 0 || W <= xx) continue;
		if (0 <= P[yy][xx]) continue;

		if (M[y][x] == '.' && M[yy][xx] == '.' && (i % 2) == 0) {
			dfs2(xx, yy, c);
		}

		if (M[y][x] == '#' && M[yy][xx] == '#') {
			dfs2(xx, yy, c);
		}
	}
}
void step1() { // ??£??????????????????????????????????????????
	rep(y, 0, H) rep(x, 0, W) P[y][x] = -1;

	N = 0;
	rep(y, 0, H) rep(x, 0, W) if(P[y][x] < 0){
		dfs2(x, y, N);
		N++;
	}
}
//-----------------------------------------------------------------
set<int> E[20101];
void step2() { // ??¨?????????
	rep(i, 0, W*H) E[i].clear();

	rep(y, 0, H) rep(x, 0, W) {
		rep(i, 0, 8) if(i % 2 == 0){
			int yy = y + dy[i];
			int xx = x + dx[i];
			if (yy < 0 || H <= yy) continue;
			if (xx < 0 || W <= xx) continue;

			if (P[y][x] != P[yy][xx]) {
				E[P[y][x]].insert(P[yy][xx]);
				E[P[yy][xx]].insert(P[y][x]);
			}
		}
	}
}
//-----------------------------------------------------------------
int D[20101];
bool done[20101];
int dfs(int cur, int par) {
	done[cur] = true;

	vector<int> hashs;
	for (int to : E[cur]) if (to != par) if(!done[to]){
		hashs.push_back(dfs(to, cur));
		D[cur] = max(D[cur], D[to] + 1);
	}

	int ret = 1;
	for (int h : hashs) ret = (1LL * ret * ((rnd[D[cur]] + h) % mod)) % mod;
	return ret;
}
//-----------------------------------------------------------------
string dfs3(int cur, int par) {
	done[cur] = true;

	vector<string> hashs;
	for (int to : E[cur]) if (to != par) if (!done[to]) {
		hashs.push_back(dfs3(to, cur));
	}

	sort(hashs.begin(), hashs.end());
	string ret = "(";
	for (string h : hashs) ret += h;
	ret += ")";

	return ret;
}
//-----------------------------------------------------------------
pair<int,string> makeHash() {
	step1();

	/*rep(y, 0, H) cout << M[y] << endl;
	rep(y, 0, H) {
	rep(x, 0, W) cout << P[y][x];
	cout << endl;
	}*/

	step2();

	/*rep(i, 0, N) for (int to : E[i]) if (i < to) {
		printf("%d %d\n", i, to);
	}*/

	rep(i, 0, H*W) D[i] = 0;
	rep(i, 0, H*W) done[i] = false;
	return { N, dfs3(0, -1) };
}
//-----------------------------------------------------------------
int main() {
	pre();

	while (cin >> H >> W) {
		if (H == 0) return 0;

		rep(y, 1, H + 1) cin >> M[y];
		M[0] = ""; rep(x, 0, W + 2) M[0] += ".";
		rep(y, 1, H + 1) M[y] = "." + M[y] + ".";
		M[H + 1] = ""; rep(x, 0, W + 2) M[H + 1] += ".";
		H += 2; W += 2;
		auto hash1 = makeHash();

		cin >> H >> W;
		rep(y, 1, H + 1) cin >> M[y];
		M[0] = ""; rep(x, 0, W + 2) M[0] += ".";
		rep(y, 1, H + 1) M[y] = "." + M[y] + ".";
		M[H + 1] = ""; rep(x, 0, W + 2) M[H + 1] += ".";
		H += 2; W += 2;
		auto hash2 = makeHash();

		if (hash1 == hash2)
			printf("yes\n");
		else
			printf("no\n");
	}
}