#include <bits/stdc++.h>
using namespace std;
int main() {
  string s = "", s1 = "", tmp;
  cin >> tmp;
  s += tmp;
  cin >> tmp;
  reverse(tmp.begin(), tmp.end());
  s += tmp;
  cin >> tmp;
  s1 += tmp;
  cin >> tmp;
  reverse(tmp.begin(), tmp.end());
  s1 += tmp;
  s.erase(s.find('X'), 1);
  s1.erase(s1.find('X'), 1);
  s += s;
  int i = 0;
  while (s[i] != s1[0]) i++;
  if (s.substr(i, 3) == s1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
