#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  vector<string> v;
  set<string> r;
  string a, b, s, p, c, d;
  cin >> a >> b >> c >> d;
  s = a + b[1] + b[0];
  p = s;
  string h = c + d[1] + d[0];
  if (s == h) {
    cout << "YES";
    return 0;
  }
  while (true) {
    for (int i = 0; i < s.length(); i++) {
      if (s[i] == 'X') {
        if (i == 3) {
          s[3] = s[0];
          s[0] = 'X';
          break;
        } else {
          s[i] = s[i + 1];
          s[i + 1] = 'X';
          break;
        }
      }
    }
    v.push_back(s);
    if (s == p) {
      break;
    }
    r.insert(s);
  }
  if (r.find(h) != r.end()) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
