#include <bits/stdc++.h>
using namespace std;
bool solve() {
  string s, s1, t, t1;
  cin >> s >> s1 >> t >> t1;
  s += s1;
  t += t1;
  swap(s[2], s[3]);
  swap(t[2], t[3]);
  s.erase(s.find('X'), 1);
  t.erase(t.find('X'), 1);
  for (int i = 0; i < 3; i++) {
    if (s == t) return true;
    rotate(s.begin(), s.begin() + 1, s.end());
  }
  return false;
}
int main() { cout << (solve() ? "YES" : "NO") << endl; }
