#include <bits/stdc++.h>
using namespace std;
map<string, int> m1, m2;
void go(string s, map<string, int>& mp) {
  if (mp.find(s) != mp.end()) {
    return;
  }
  mp[s] = 1;
  if (s[0] == 'X') {
    string s1 = s;
    string s2 = s;
    swap(s1[0], s1[1]);
    swap(s2[0], s2[2]);
    go(s1, mp);
    go(s2, mp);
  } else if (s[1] == 'X') {
    string s1 = s;
    string s2 = s;
    swap(s1[1], s1[0]);
    swap(s2[1], s2[3]);
    go(s1, mp);
    go(s2, mp);
  } else if (s[3] == 'X') {
    string s1 = s;
    string s2 = s;
    swap(s1[3], s1[1]);
    swap(s2[3], s2[2]);
    go(s1, mp);
    go(s2, mp);
  } else {
    string s1 = s;
    string s2 = s;
    swap(s1[2], s1[0]);
    swap(s2[2], s2[3]);
    go(s1, mp);
    go(s2, mp);
  }
}
int main() {
  string tmp;
  string a;
  cin >> a;
  cin >> tmp;
  a += tmp;
  string b;
  cin >> b;
  cin >> tmp;
  b += tmp;
  go(a, m1);
  go(b, m2);
  int done = 0;
  for (auto it : m1) {
    if (m2[it.first]) {
      done = 1;
      cout << "YES" << endl;
      break;
    }
  }
  if (!done) {
    cout << "NO" << endl;
  }
  return 0;
}
