迷惑喵喵
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define RI register int
using namespace std;
int n;
string a, b;
void era(string &s)
{
string result;
for (int i = 0; i < s.size();)
{
if (i < s.size() - 2 and (((s[i] == 'A') and (s[i + 1] == 'B') and (s[i + 2] == 'C')) or ((s[i] == 'B') and (s[i + 1] == 'C') and (s[i + 2] == 'A')) or ((s[i] == 'C') and (s[i + 1] == 'A') and (s[i + 2] == 'B'))))
{
i += 3;
}
else
{
result += s[i];
i++;
}
}
s = result;
}
int main()
{
cin >> n >> a >> b;
era(a);
era(b);
if (a == b)
{
cout << "YES" << endl;
}
else
{
cout << "NO" << endl;
}
return 0;
}