#include <bits/stdc++.h>
using namespace std;
string del(string s) {
  string ss = "";
  for (int i = 0; i < 4; i++)
    if (s[i] != 'X') ss += s[i];
  return ss;
}
int main() {
  string a = "", b = "";
  char x, y;
  cin >> x >> y;
  a += x;
  a += y;
  cin >> x >> y;
  a += y;
  a += x;
  cin >> x >> y;
  b += x;
  b += y;
  cin >> x >> y;
  b += y;
  b += x;
  a = del(a);
  b = del(b);
  string b1 = b[2] + b.substr(0, 2);
  string b2 = b.substr(1, 2) + b[0];
  if (a == b || a == b1 || a == b2)
    cout << "YES";
  else
    cout << "NO";
  cout << endl;
}
