#include <bits/stdc++.h>
using namespace std;
string a, b;
void g(string &a) {
  if (a[1] == 'X') {
    swap(a[0], a[1]);
  } else if (a[2] == 'X') {
    swap(a[2], a[0]);
  } else if (a[3] == 'X') {
    swap(a[2], a[3]);
    swap(a[2], a[0]);
  }
}
void f(string &a) {
  g(a);
  for (int i = 0; i < 4; ++i) {
    if (a[i] == 'X') {
      a.erase(a.begin() + i);
      return;
    }
  }
}
int main() {
  string tmp;
  cin >> a;
  cin >> tmp;
  a += tmp;
  cin >> b;
  cin >> tmp;
  b += tmp;
  f(a);
  f(b);
  b += b;
  for (int i = 0; i < 3; ++i) {
    if (b.substr(i, 3) == a) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
