#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1e9 + 7;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<class T>
istream& operator >> (istream& is, vector<T>& v)
{
	for (auto &i : v) is >> i;
	return is;
}
template<class T>
ostream& operator<<(ostream& os, vector<T>& v)
{
	const string delimiter = "\n";
	REP(i, v.size())
	{
		os << v[i];
		if (i != v.size() - 1) os << delimiter;
	}
	return os;
}
/*--------------------template--------------------*/

const ll leaf = 1007;

const int dx0[] = { -1, 0, 1, 0 }, dy0[] = { 0, -1, 0, 1 };
const int dx1[] = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy1[] = { 0, -1, 1, -1, 1, 0, -1, 1 };
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }


int h, w;
vector<string> p;

ll get_hash(int v, const vector<vi>& tree)
{
	if (tree[v].size() == 0) return leaf;
	ll sum = 0;
	for (auto u : tree[v])
	{
		sum += get_hash(u, tree);
		sum %= MOD;
	}
	sum *= sum;
	return sum + 1;
}

ll calc()
{
	p.clear();
	cin >> h >> w;
	if (h == 0 && w == 0) exit(EXIT_SUCCESS);
	p.resize(h + 2);
	p[0] = p[h + 1] = string(w + 2, '.');
	FOR(i, 1, h + 1)
	{
		p[i].push_back('.');
		string s; cin >> s;
		p[i] += s;
		p[i].push_back('.');
	}
	vector<vi> tree;
	int cnt = 0;
	vector<vector<int>> group(h + 2, vector<int>(w + 2, -1));
	queue<pair<pii, int>> que;
	que.emplace(pii(0, 0), -1);
	while (!que.empty())
	{
		int x = que.front().first.first;
		int y = que.front().first.second;
		int par = que.front().second;
		que.pop();
		if (group[x][y] != -1) continue;
		int index = cnt;
		tree.push_back({});
		cnt++;
		group[x][y] = index;
		if (par >= 0) tree[par].push_back(index);
		queue<pii> que2;
		que2.emplace(x, y);
		int color = (p[x][y] == '.' ? 0 : 1);
		while (!que2.empty())
		{
			int tx = que2.front().first;
			int ty = que2.front().second;
			que2.pop();
			if (color == 0)
			{
				REP(i, 4)
				{
					int nx = tx + dx0[i];
					int ny = ty + dy0[i];
					if (!valid(nx, ny, h + 2, w + 2) || group[nx][ny] >= 0) continue;
					if (p[nx][ny] == '.')
					{
						group[nx][ny] = index;
						que2.emplace(nx, ny);
					}
					else
					{
						que.emplace(pii(nx, ny), index);
					}
				}
			}
			else
			{
				REP(i, 8)
				{
					int nx = tx + dx1[i];
					int ny = ty + dy1[i];
					if (!valid(nx, ny, h + 2, w + 2) || group[nx][ny] >= 0) continue;
					if (p[nx][ny] == '#')
					{
						group[nx][ny] = index;
						que2.emplace(nx, ny);
					}
					else
					{
						que.emplace(pii(nx, ny), index);
					}
				}
			}
		}
	}
	/*
	REP(i, h + 2) cout << p[i] << endl;
	REP(i, h + 2)
	{
		REP(j, w + 2) cout << group[i][j];
		cout << endl;
	}
	REP(i, tree.size())
	{
		REP(j, tree[i].size()) cout << tree[i][j] << " ";
		cout << endl;
	}
	*/
	return get_hash(0, tree);
}

int main()
{
	while (1)
	{
		ll a = calc();
		ll b = calc();
		cout << (a == b ? "yes" : "no") << endl;
	}
	return 0;
}

Measured memory_bytes: 3228