#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }
int main()
{
    while (true) {
        constexpr int w[] = {1, 0, -1, 0, 1};
        constexpr int b[] = {1, -1, 0, 1, 0, -1, -1, 1, 1};
        auto graph = [&w,&b]() -> vector<vector<int>> {
            int H, W;
            cin >> H >> W;
            if (H == 0 and W == 0) { return vector<vector<int>>{}; }
            vector<vector<char>> f(H + 2, vector<char>(W + 2, '.'));
            for (int i = 1; i <= H; i++) {
                for (int j = 1; j <= W; j++) { cin >> f[i][j]; }
            }
            auto win = [&](const int i, const int j) { return i >= 0 and i < H + 2 and j >= 0 and j < W + 2 and f[i][j] == '.'; };
            auto bin = [&](const int i, const int j) { return i >= 0 and i < H + 2 and j >= 0 and j < W + 2 and f[i][j] == '#'; };
            vector<vector<int>> comp(H + 2, vector<int>(W + 2, -1));
            int c = 0;
            vector<vector<int>> ans;
            for (int i = 0; i < H + 2; i++) {
                for (int j = 0; j < W + 2; j++) {
                    if (comp[i][j] != -1) { continue; }
                    using P = pair<int, int>;
                    queue<P> q;
                    q.push({i, j}), comp[i][j] = c;
                    ans.push_back(vector<int>{});
                    if (c > 0) { ans[comp[i - 1][j]].push_back(c); }
                    while (not q.empty()) {
                        const int y = q.front().first, x = q.front().second;
                        q.pop();
                        if (f[y][x] == '.') {
                            for (int d = 0; d < 4; d++) {
                                const int newy = y + w[d], newx = x + w[d + 1];
                                if (not win(newy, newx) or comp[newy][newx] != -1) { continue; }
                                q.push({newy, newx}), comp[newy][newx] = c;
                            }
                        } else {
                            for (int d = 0; d < 8; d++) {
                                const int newy = y + b[d], newx = x + b[d + 1];
                                if (not bin(newy, newx) or comp[newy][newx] != -1) { continue; }
                                q.push({newy, newx}), comp[newy][newx] = c;
                            }
                        }
                    }
                    c++;
                }
            }
            return ans;
        };
        const auto g1 = graph();
        if (g1.empty()) { break; }
        const auto g2 = graph();
        if (g1.size() != g2.size()) {
            cout << "no" << endl;
            continue;
        }
        const int sz = g1.size();
        vector<ll> hash(sz);
        mt19937 mt{random_device{}()};
        uniform_int_distribution<ll> dist{2, MOD - 1};
        for (auto& e : hash) { e = dist(mt); }
        auto getHash = fix([&hash](auto&& self, const int s, const int d, const vector<vector<int>>& g) -> ll {
            ll prod = 1;
            for (const int to : g[s]) {
                const ll sub = self(self, to, d + 1, g);
                (prod *= (sub + hash[d])) %= MOD;
            }
            return prod;
        });
        cout << (getHash(0, 0, g1) == getHash(0, 0, g2) ? "yes" : "no") << endl;
    }
    return 0;
}



Measured memory_bytes: 3276