#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2, s3, s4, ans, ans2;
  int a = 0;
  vector<char> v;
  vector<char> v2;
  cin >> s1 >> s2 >> s3 >> s4;
  char c[4] = {s3[0], s3[1], s4[1], s4[0]};
  for (int i = 0; i < 2; i++) {
    if (s1[i] != 'X') v.push_back(s1[i]);
  }
  for (int i = 1; i >= 0; i--)
    if (s2[i] != 'X') v.push_back(s2[i]);
  while (1) {
    if (c[a] == v[0]) {
      a++;
      a %= 4;
      if (c[a] != 'X') {
        a %= 4;
        if (c[a] == v[1]) {
          cout << "YES";
        } else {
          cout << "NO";
        }
      } else {
        a++;
        a %= 4;
        if (c[a] == v[1]) {
          cout << "YES";
        } else {
          cout << "NO";
        }
      }
      break;
    }
    a++;
    a %= 4;
  }
}
