#include <bits/stdc++.h>
using namespace std;
void read(char *a) {
  char b[2][2];
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) cin >> b[i][j];
  if (b[0][0] == 'X') {
    a[0] = b[0][1];
    a[1] = b[1][1];
    a[2] = b[1][0];
  } else if (b[0][1] == 'X') {
    a[0] = b[0][0];
    a[1] = b[1][1];
    a[2] = b[1][0];
  } else if (b[1][0] == 'X') {
    a[0] = b[0][0];
    a[1] = b[0][1];
    a[2] = b[1][1];
  } else {
    a[0] = b[0][0];
    a[1] = b[0][1];
    a[2] = b[1][0];
  }
  while (a[0] != 'A') {
    char t = a[0];
    a[0] = a[1];
    a[1] = a[2];
    a[2] = t;
  }
}
bool is_eq(char *a, char *b, int n) {
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) return false;
  return true;
}
int main() {
  char a[3];
  char b[3];
  read(a);
  read(b);
  cout << (is_eq(a, b, 3) ? "YES" : "NO") << endl;
  return 0;
}
