#include <bits/stdc++.h>
using namespace std;

struct data {
  int x, y;
  bool operator<(const data& r) const {
    if(x != r.x) return x < r.x;
    return y < r.y;
  }
};

int d[4] = {0, 1, 0, -1};
int h1, h2, w1, w2;
vector<string> s1, s2;
vector<vector<bool>> b1, b2;
string mp = ".#";

bool isvalid(int h, int w, data now) {
  return now.x >= 0 && now.x < h && now.y >= 0 && now.y < w;
}
string solve(int& h, int& w, vector<vector<bool>>& b);
string dfs(int& h, int& w, vector<vector<bool>>& b,
           vector<vector<bool>>& used, data now);

int main() {
  while(1) {
    cin >> h1 >> w1;
    if(h1 + w1 == 0) break;
    s1.resize(h1 + 2);
    for(int i = 0; i < h1; ++i) cin >> s1[i];
    b1.assign(h1 + 2, vector<bool>(w1 + 2, 0));
    for(int i = 0; i < h1; ++i)
      for(int j = 0; j < w1; ++j)
        b1[i + 1][j + 1] = s1[i][j] == '#';
    cin >> h2 >> w2;
    s2.resize(h2);
    for(int i = 0; i < h2; ++i) cin >> s2[i];
    b2.assign(h2 + 2, vector<bool>(w2 + 2, 0));
    for(int i = 0; i < h2; ++i)
      for(int j = 0; j < w2; ++j)
        b2[i + 1][j + 1] = s2[i][j] == '#';
    h1 += 2;
    w1 += 2;
    h2 += 2;
    w2 += 2;
    if(solve(h1, w1, b1) == solve(h2, w2, b2))
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

string solve(int& h, int& w, vector<vector<bool>>& b) {
  vector<vector<bool>> used(h, vector<bool>(w, 0));
  //  string res = dfs(h, w, b, used, {0, 0});
  return dfs(h, w, b, used, {0, 0});
}
string dfs(int& h, int& w, vector<vector<bool>>& b,
           vector<vector<bool>>& used, data now) {
  string res = "(";
  res += mp[b[now.x][now.y]];
  vector<string> chil;
  set<data> to;
  queue<data> qu;
  qu.push(now);
  used[now.x][now.y] = 1;
  while(qu.size()) {
    now = qu.front();
    qu.pop();
    // black part
    if(b[now.x][now.y]) {
      for(int i = -1; i <= 1; ++i)
        for(int j = -1; j <= 1; ++j)
          if(i != j || i != 0) {
            data nextp = now;
            nextp.x += i;
            nextp.y += j;
            if(!isvalid(h, w, nextp) ||
               used[nextp.x][nextp.y])
              continue;
            if(b[nextp.x][nextp.y]) {
              used[nextp.x][nextp.y] = 1;
              qu.push(nextp);
            }
            else
              to.insert(nextp);
          }
    }
    // white part
    else {
      for(int i = 0; i < 4; ++i) {
        data nextp = now;
        nextp.x += d[i];
        nextp.y += d[1 ^ i];
        if(!isvalid(h, w, nextp) || used[nextp.x][nextp.y])
          continue;
        if(!b[nextp.x][nextp.y]) {
          used[nextp.x][nextp.y] = 1;
          qu.push(nextp);
        }
        else
          to.insert(nextp);
      }
    }
  }

  for(auto p : to)
    if(!used[p.x][p.y])
      chil.push_back(dfs(h, w, b, used, p));
  sort(chil.begin(), chil.end());
  for(auto& t : chil) res += t;
  return res + ")";
}
