#include<bits/stdc++.h>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define INF 1e18
#define nline "\n"
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define set_bits __builtin_popcountll
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update > pbds; // find_by_order, order_of_key
#ifndef ONLINE_JUDGE
#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;
#else
#define debug(x)
#endif
void _print(ll t) {cerr << t;}
void _print(int t) {cerr << t;}
void _print(string t) {cerr << t;}
void _print(char t) {cerr << t;}
void _print(lld t) {cerr << t;}
void _print(double t) {cerr << t;}
void _print(ull t) {cerr << t;}
template <class T, class V> void _print(pair <T, V> p);
template <class T> void _print(vector <T> v);
template <class T> void _print(set <T> v);
template <class T, class V> void _print(map <T, V> v);
template <class T> void _print(multiset <T> v);
template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}
template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}
template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}
void TestCase();
int main()
{
fastio();
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
freopen("Error.txt", "w", stderr);
#endif
int T=1;
//cin>>T;
while(T--)
TestCase();
return 0;
}
void rotatematrix(int n, vector<vector<char>> &a)
{
vector<vector<char>> tmp(n,vector<char> (n));
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
tmp[i][j]=a[n-1-j][i];
}
}
a=tmp;
}
void TestCase()
{
int n;
cin>>n;
vector<vector<char>> a(n,vector<char> (n));
vector<vector<char>> b(n,vector<char> (n));
vector<pair<int,int>> s;
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
char c;
cin>>c;
a[i][j]=c;
if(c=='#')
{
s.pb({i,j});
}
}
}
vector<pair<int,int>> t;
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
char c;
cin>>c;
b[i][j]=c;
if(c=='#')
{
t.pb({i,j});
}
}
}
debug(s);
debug(t);
if(sz(s)!=sz(t))
{
cout<<"No\n";
}
else{
for(int z=0;z<4;++z)
{
rotatematrix(n,a);
s.clear();
for(int i=0;i<n;++i)
{
for(int j=0;j<n;++j)
{
if(a[i][j]=='#')
{
s.pb({i,j});
}
}
}
int diff=abs(s[0].first - t[0].first) + abs(s[0].second - t[0].second);
bool stat=true;
for(int w=1;w<sz(s);++w)
{
int diff1=abs(s[w].first - t[w].first) + abs(s[w].second - t[w].second);
if(diff1!=diff)
{
stat=false;
break;
}
}
if(stat)
{
cout<<"Yes\n";
return;
}
}
cout<<"No\n";
}
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgoKCiNkZWZpbmUgZmFzdGlvKCkgaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7Y2luLnRpZShOVUxMKTtjb3V0LnRpZShOVUxMKQojZGVmaW5lIE1PRCAxMDAwMDAwMDA3CiNkZWZpbmUgTU9EMSA5OTgyNDQzNTMKI2RlZmluZSBJTkYgMWUxOAojZGVmaW5lIG5saW5lICJcbiIKI2RlZmluZSBwYiBwdXNoX2JhY2sKI2RlZmluZSBwcGIgcG9wX2JhY2sKI2RlZmluZSBtcCBtYWtlX3BhaXIKI2RlZmluZSBmZi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UZXN0Q2FzZSgpOwoKaW50IG1haW4oKQp7CiAgIGZhc3RpbygpOwogICAKICAgI2lmbmRlZiBPTkxJTkVfSlVER0UKICAgZnJlb3BlbigiaW5wdXQudHh0IiwgInIiLCBzdGRpbik7CiAgIGZyZW9wZW4oIm91dHB1dC50eHQiLCAidyIsIHN0ZG91dCk7CiAgIGZyZW9wZW4oIkVycm9yLnR4dCIsICJ3Iiwgc3RkZXJyKTsKICAgI2VuZGlmCiAgIAogICBpbnQgVD0xOwogICAvL2Npbj4+VDsKICAgd2hpbGUoVC0tKQogICBUZXN0Q2FzZSgpOwoKICAgcmV0dXJuIDA7Cn0KCnZvaWQgcm90YXRlbWF0cml4KGludCBuLCB2ZWN0b3I8dmVjdG9yPGNoYXI+PiAmYSkKewogICAgdmVjdG9yPHZlY3RvcjxjaGFyPj4gdG1wKG4sdmVjdG9yPGNoYXI+IChuKSk7CiAgICBmb3IoaW50IGk9MDtpPG47KytpKQogICAgewogICAgICAgIGZvcihpbnQgaj0wO2o8bjsrK2opCiAgICAgICAgewogICAgICAgICAgICB0bXBbaV1bal09YVtuLTEtal1baV07CiAgICAgICAgfQogICAgfQogICAgYT10bXA7Cn0KCnZvaWQgVGVzdENhc2UoKQp7CiAgICBpbnQgbjsKICAgIGNpbj4+bjsKICAgIHZlY3Rvcjx2ZWN0b3I8Y2hhcj4+IGEobix2ZWN0b3I8Y2hhcj4gKG4pKTsKICAgIHZlY3Rvcjx2ZWN0b3I8Y2hhcj4+IGIobix2ZWN0b3I8Y2hhcj4gKG4pKTsKICAgIHZlY3RvcjxwYWlyPGludCxpbnQ+PiBzOwogICAgZm9yKGludCBpPTA7aTxuOysraSkKICAgIHsKICAgICAgICBmb3IoaW50IGo9MDtqPG47KytqKQogICAgICAgIHsKICAgICAgICAgICAgY2hhciBjOwogICAgICAgICAgICBjaW4+PmM7CiAgICAgICAgICAgIGFbaV1bal09YzsKICAgICAgICAgICAgaWYoYz09JyMnKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBzLnBiKHtpLGp9KTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIHZlY3RvcjxwYWlyPGludCxpbnQ+PiB0OwogICAgZm9yKGludCBpPTA7aTxuOysraSkKICAgIHsKICAgICAgICBmb3IoaW50IGo9MDtqPG47KytqKQogICAgICAgIHsKICAgICAgICAgICAgY2hhciBjOwogICAgICAgICAgICBjaW4+PmM7CiAgICAgICAgICAgIGJbaV1bal09YzsKICAgICAgICAgICAgaWYoYz09JyMnKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB0LnBiKHtpLGp9KTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGRlYnVnKHMpOwogICAgZGVidWcodCk7CiAgICBpZihzeihzKSE9c3oodCkpCiAgICB7CiAgICAgICAgY291dDw8Ik5vXG4iOwogICAgfQogICAgZWxzZXsKICAgICAgICBmb3IoaW50IHo9MDt6PDQ7Kyt6KQogICAgICAgIHsKICAgICAgICAgICAgcm90YXRlbWF0cml4KG4sYSk7CiAgICAgICAgICAgIHMuY2xlYXIoKTsKICAgICAgICAgICAgZm9yKGludCBpPTA7aTxuOysraSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgZm9yKGludCBqPTA7ajxuOysraikKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBpZihhW2ldW2pdPT0nIycpCiAgICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgICAgICBzLnBiKHtpLGp9KTsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaW50IGRpZmY9YWJzKHNbMF0uZmlyc3QgLSB0WzBdLmZpcnN0KSArIGFicyhzWzBdLnNlY29uZCAtIHRbMF0uc2Vjb25kKTsKICAgICAgICAgICAgYm9vbCBzdGF0PXRydWU7CiAgICAgICAgICAgIGZvcihpbnQgdz0xO3c8c3oocyk7Kyt3KQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpbnQgZGlmZjE9YWJzKHNbd10uZmlyc3QgLSB0W3ddLmZpcnN0KSArIGFicyhzW3ddLnNlY29uZCAtIHRbd10uc2Vjb25kKTsKICAgICAgICAgICAgICAgIGlmKGRpZmYxIT1kaWZmKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHN0YXQ9ZmFsc2U7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYoc3RhdCkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY291dDw8Illlc1xuIjsKICAgICAgICAgICAgICAgIHJldHVybjsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb3V0PDwiTm9cbiI7CiAgICB9Cn0=