#include <bits/stdc++.h>
using namespace std;
int main() {
  string a1, a2, b1, b2;
  cin >> a1 >> a2 >> b1 >> b2;
  swap(a2[0], a2[1]);
  swap(b2[0], b2[1]);
  string a = a1 + a2;
  string b = b1 + b2;
  a.erase(a.find('X'), 1);
  b.erase(b.find('X'), 1);
  int k = (a + a).find(b);
  if (k != -1) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
