#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

int bx[8] = {1, 1, 1, 0, -1, -1, -1, 0}, by[8] = {1, 0, -1, -1, -1, 0, 1, 1};
int wx[4] = {1, 0, -1, 0}, wy[4] = {0, -1, 0, 1};

string dfs(int x, int y, vector<vector<int>> &usd, const vector<vector<int>> &v)
{
    //cerr << x << " " << y << endl;
    int h = v.size();
    int w = v[0].size();
    usd[x][y] = 1;
    queue<P> que;
    que.push(P(x, y));
    vector<P> nxt;
    while (!que.empty())
    {
        auto p = que.front();
        que.pop();
        if (v[x][y])
        {
            // black
            for (int i = 0; i < 8; i++)
            {
                int nx = p.first + bx[i], ny = p.second + by[i];
                if (nx < 0 || h <= nx || ny < 0 || w <= ny || usd[nx][ny])
                    continue;
                if (v[nx][ny] != v[x][y])
                    nxt.push_back(P(nx, ny));
                else
                {
                    usd[nx][ny] = 1;
                    que.push(P(nx, ny));
                }
            }
        }
        else
        {
            // white
            for (int i = 0; i < 4; i++)
            {
                int nx = p.first + wx[i], ny = p.second + wy[i];
                if (nx < 0 || h <= nx || ny < 0 || w <= ny || usd[nx][ny])
                    continue;
                if (v[nx][ny] != v[x][y])
                    nxt.push_back(P(nx, ny));
                else
                {
                    usd[nx][ny] = true;
                    que.push(P(nx, ny));
                }
            }
        }
    }
    string ret = "(";
    vector<string> ch;
    for (auto p : nxt)
    {
        if (usd[p.first][p.second])
            continue;
        ch.push_back(dfs(p.first, p.second, usd, v));
    }
    sort(ch.begin(), ch.end());
    for (const auto &s : ch)
        ret += s;
    ret += ")";
    return ret;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int h1, w1;
    while (cin >> h1 >> w1, h1 || w1)
    {
        vector<string> s1(h1);
        vector<vector<int>> v1(h1 + 2, vector<int>(w1 + 2, 0));
        for (int i = 0; i < h1; i++)
        {
            cin >> s1[i];
            for (int j = 0; j < w1; j++)
            {
                if (s1[i][j] == '#')
                {
                    v1[i + 1][j + 1] = 1;
                }
            }
        }
        int h2, w2;
        cin >> h2 >> w2;
        vector<string> s2(h2);
        vector<vector<int>> v2(h2 + 2, vector<int>(w2 + 2, 0));
        for (int i = 0; i < h2; i++)
        {
            cin >> s2[i];
            for (int j = 0; j < w2; j++)
            {
                if (s2[i][j] == '#')
                {
                    v2[i + 1][j + 1] = 1;
                }
            }
        }
        vector<vector<int>> usd1(h1 + 2, vector<int>(w1 + 2, 0));
        vector<vector<int>> usd2(h2 + 2, vector<int>(w2 + 2, 0));
        cout << (dfs(0, 0, usd1, v1) == dfs(0, 0, usd2, v2) ? "yes" : "no") << endl;
    }
}



Measured memory_bytes: 3352