#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
int main() {
  string s1, s2, s3, s4;
  cin >> s1 >> s2 >> s3 >> s4;
  swap(s2[0], s2[1]);
  string p = s1 + s2;
  swap(s4[0], s4[1]);
  string q = s3 + s4;
  p.erase(p.begin() + p.find('X'));
  q.erase(q.begin() + q.find('X'));
  string temp = p + p;
  for (int i = 0; i <= 3; i++) {
    bool flag = true;
    for (int j = i; j < i + 3; j++) {
      if (temp[j] != q[j - i]) flag = false;
    }
    if (flag) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}
