#include <bits/stdc++.h>
using namespace std;
int soniguales(char* a, char* b) {
  for (int i = 0; i < 3; i++) {
    if (a[i] != b[i]) return 0;
  }
  return 1;
}
int main() {
  char a[6];
  char b[4];
  cin >> a[0] >> a[1];
  cin >> a[3] >> a[2];
  cin >> b[0] >> b[1];
  cin >> b[3] >> b[2];
  for (int i = 0; i < 3; i++) {
    if (a[i] == 'X')
      a[i] = a[i + 1];
    else if (i > 0 && a[i] == a[i - 1])
      a[i] = a[i + 1];
    if (b[i] == 'X')
      b[i] = b[i + 1];
    else if (i > 0 && b[i] == b[i - 1])
      b[i] = b[i + 1];
  }
  for (int i = 0; i < 3; i++) {
    a[3 + i] = a[i];
  }
  for (int i = 0; i < 3; i++) {
    if (soniguales(a + i, b)) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
