#include <bits/stdc++.h>
using namespace std;
const char x = 'X';
string f1, f2, s1, s2, fres, sres;
int main() {
  cin >> f1 >> f2 >> s1 >> s2;
  swap(f2[0], f2[1]);
  swap(s2[0], s2[1]);
  fres = f1 + f2, sres = s1 + s2;
  fres.erase(fres.find(x), 1);
  sres.erase(sres.find(x), 1);
  if ((fres + fres).find(sres) == string ::npos)
    cout << "NO";
  else
    cout << "YES";
}
