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