#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s1, s2, s3, s4;
  cin >> s1 >> s2 >> s3 >> s4;
  char x1 = s1[0];
  char y1 = s1[1];
  char x2 = s2[0];
  char y2 = s2[1];
  char x3 = s3[0];
  char y3 = s3[1];
  char x4 = s4[0];
  char y4 = s4[1];
  if (x1 == x3 && x2 == x4 && y1 == y3 && y2 == y4) {
    cout << "YES" << endl;
    return 0;
  }
  for (int i = 0; i < 50; i++) {
    if (x1 == 'X') {
      swap(x1, y1);
      if (x1 == x3 && x2 == x4 && y1 == y3 && y2 == y4) {
        cout << "YES" << endl;
        return 0;
      }
    }
    if (y1 == 'X') {
      swap(y1, y2);
      if (x1 == x3 && x2 == x4 && y1 == y3 && y2 == y4) {
        cout << "YES" << endl;
        return 0;
      }
    }
    if (y2 == 'X') {
      swap(y2, x2);
      if (x1 == x3 && x2 == x4 && y1 == y3 && y2 == y4) {
        cout << "YES" << endl;
        return 0;
      }
    }
    if (x2 == 'X') {
      swap(x2, x1);
      if (x1 == x3 && x2 == x4 && y1 == y3 && y2 == y4) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;
  return 0;
}
