#include <bits/stdc++.h>
using namespace std;
int main() {
  string t1, t2, t3, t4;
  cin >> t1 >> t2 >> t3 >> t4;
  string b = t1 + t2[1] + t2[0], e = t3 + t4[1] + t4[0];
  b.erase(b.find('X'), 1);
  e.erase(e.find('X'), 1);
  for (int i = 0; i < 3; ++i) {
    string a1 = e.substr(i);
    string a2 = e.substr(0, i);
    if (b == a1 + a2) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
