#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2, s3, s4;
  cin >> s1 >> s2 >> s3 >> s4;
  swap(s2[0], s2[1]);
  swap(s4[0], s4[1]);
  string str1 = s1 + s2;
  string str2 = s3 + s4;
  str1.erase(str1.find('X'), 1);
  str2.erase(str2.find('X'), 1);
  if ((str1 + str1).find(str2) != string::npos) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
