#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long llinf = 1e18 + 7;
const double eps = 1e-15;
const int mod = 1e9 + 7;
string a, b, x;
int main() {
  ios::sync_with_stdio(false);
  a = "";
  b = "";
  bool f = 0;
  cin >> x;
  a += x;
  cin >> x;
  a += x[1];
  a += x[0];
  cin >> x;
  b += x;
  cin >> x;
  b += x[1];
  b += x[0];
  if (a == b) {
    cout << "YES";
    return 0;
  }
  a.erase(a.begin() + a.find('X'));
  b.erase(b.begin() + b.find('X'));
  for (int i = 0; i < 3; i++) {
    rotate(&a[0], &a[1], &a[3]);
    if (a == b) {
      f = 1;
      break;
    }
  }
  if (f)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
