#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const int dy[] = {1, 0, -1, 0, -1, 1, -1, 1};
const int dx[] = {0, 1, 0, -1, -1, -1, 1, 1};

struct Image {
  int h, w;
  char p[111][111];
  vector< set<int> > graph;
  bool input() {
    rep(i, 111) rep(j, 111) p[i][j] = '.';
    cin >> h >> w;
    if(!h && !w) return false;
    reps(i, 1, h+1) reps(j, 1, w+1) cin >> p[i][j];
    //cout << "input finished" << endl;
    return true;
  }
  bool in(int y, int x) {
    return 0<=y&&y<=h+1&&0<=x&&x<=w+1;
  }
  void make() {
    int num[111][111];
    int sz = 0;
    memset(num, -1, sizeof(num));
    rep(i, h+2) rep(j, w+2) {
      if(~num[i][j]) continue;
      queue<Pi> que;
      que.emplace(i, j);
      num[i][j] = sz++;
      int lim = (p[i][j] == '#' ? 8 : 4);
      while(!que.empty()) {
	int y, x;
	tie(y, x) = que.front(); que.pop();
	rep(k, lim) {
	  int ny = y + dy[k], nx = x + dx[k];
	  if(in(ny, nx) && p[ny][nx] == p[i][j] && num[ny][nx] == -1) {
	    que.emplace(ny, nx);
	    num[ny][nx] = num[i][j];
	  }
	}
      }
    }
    graph.clear();
    graph.resize(sz);
    bool used[111][111];
    memset(used, false, sizeof(used));
    rep(i, h+2) rep(j, w+2) {
      assert(~num[i][j]);
      if(used[i][j]) continue;
      queue<Pi> que;
      que.emplace(i, j);
      used[i][j] = true;
      int lim = (p[i][j] == '#' ? 8 : 4);
      while(!que.empty()) {
	int y, x;
	tie(y, x) = que.front(); que.pop();
	rep(k, lim) {
	  int ny = y + dy[k], nx = x + dx[k];
	  if(in(ny, nx) && !used[ny][nx]) {
	    if(p[ny][nx] == p[i][j]) {
	      que.emplace(ny, nx);
	      used[ny][nx] = true;
	    } else {
	      graph[num[i][j]].insert(num[ny][nx]);
	    }
	  }
	}
      }
    }
  }
  string dfs(int v) {
    vector<string> ch;
    for(int u : graph[v]) {
      ch.push_back(dfs(u));
    }
    sort(all(ch));
    string res = "";
    for(string s : ch) res += s;
    return "0"+res+"1";
  }
  string hash() {
    //cout << "get hash" << endl;
    return dfs(0);
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Image im1, im2;
  while(im1.input()) {
    im1.make();
    im2.input(); im2.make();
    cout << (im1.hash() == im2.hash() ? "yes" : "no") << endl;
  }

  return 0;
}