#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<string> a1(n), b1(n);
  for (int i = 0; i < n; i++) {
    cin >> a1[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b1[i];
  }
  vector<long long> r1(n, 0), c1(n, 0), r2(n, 0), c2(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (a1[i][j] == 'X') {
        r1[i]++;
        c1[j]++;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (b1[i][j] == 'X') {
        r2[i]++;
        c2[j]++;
      }
    }
  }
  vector<long long> r1_r(r1.rbegin(), r1.rend());
  vector<long long> c1_r(c1.rbegin(), c1.rend());
  vector<long long> r2_r(r2.rbegin(), r2.rend());
  vector<long long> c2_r(c2.rbegin(), c2.rend());
  if (r1 == r2 && c1 == c2) {
    cout << "Yes";
    return 0;
  }
  if (r1 == r2 && c1 == c2_r) {
    cout << "Yes";
    return 0;
  }
  if (r1 == r2_r && c1 == c2) {
    cout << "Yes";
    return 0;
  }
  if (r1 == r2_r && c1 == c2_r) {
    cout << "Yes";
    return 0;
  }
  if (r1 == c2 && c1 == r2) {
    cout << "Yes";
    return 0;
  }
  if (r1 == c2 && c1 == r2_r) {
    cout << "Yes";
    return 0;
  }
  if (r1 == c2_r && c1 == r2) {
    cout << "Yes";
    return 0;
  }
  if (r1 == c2_r && c1 == r2_r) {
    cout << "Yes";
    return 0;
  }
  cout << "No";
  return 0;
}
