#include <bits/stdc++.h>
using namespace std;
int n;
bool isEqual(vector<string> a, vector<string> b) {
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) return false;
  return true;
}
vector<string> rotate(vector<string> a) {
  vector<string> res;
  for (int i = 0; i < a.size(); i++) res.push_back(a[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) res[j][n - 1 - i] = a[i][j];
  return res;
}
vector<string> flipVertical(vector<string> a) {
  vector<string> res;
  for (int i = 0; i < a.size(); i++) res.push_back(a[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) res[n - 1 - i][j] = a[i][j];
  return res;
}
vector<string> flipHorizontal(vector<string> a) {
  vector<string> res;
  for (int i = 0; i < a.size(); i++) res.push_back(a[i]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) res[i][n - 1 - j] = a[i][j];
  return res;
}
int main() {
  cin >> n;
  vector<string> p(n), q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int j = 0; j < n; j++) cin >> q[j];
  vector<string> flipV, flipH;
  flipV = flipVertical(p);
  flipH = flipHorizontal(p);
  for (int i = 0; i < 4; i++) {
    if (isEqual(p, q)) {
      cout << "YES" << endl;
      return 0;
    }
    p = rotate(p);
  }
  p = flipV;
  for (int i = 0; i < 4; i++) {
    if (isEqual(p, q)) {
      cout << "YES" << endl;
      return 0;
    }
    p = rotate(p);
  }
  p = flipH;
  for (int i = 0; i < 4; i++) {
    if (isEqual(p, q)) {
      cout << "YES" << endl;
      return 0;
    }
    p = rotate(p);
  }
  cout << "NO" << endl;
  return 0;
}
