#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, a1, b, b1;
  int n = -1, t;
  cin >> a >> a1 >> b >> b1;
  a = a + a1[1] + a1[0];
  b = b + b1[1] + b1[0];
  for (int i = 0; i < 4; i++) {
    if (a[i] == 'X') {
      n = i;
      break;
    }
  }
  for (int i = 0; i < 12; i++) {
    t = (n + 1) % 4;
    a[n] = a[t];
    a[t] = 'X';
    n = t;
    if (a == b) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO";
}
