#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int i, j, check = 0;
  string a, c, b;
  cin >> a >> b;
  b[0] ^= b[1] ^= b[0] ^= b[1];
  a.append(b);
  a.erase(a.begin() + a.find("X"));
  a.append(a);
  cin >> c >> b;
  b[0] ^= b[1] ^= b[0] ^= b[1];
  c.append(b);
  c.erase(c.begin() + c.find("X"));
  if (a.find(c) != string::npos) check = 1;
  if (check)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
