#include <bits/stdc++.h>
using namespace std;
char a[5], b[5];
inline bool solve() {
  bool judge;
  int tmp;
  if (a[1] == b[1] && a[2] == b[2] && a[3] == b[3] && a[4] == b[4])
    judge = 1;
  else
    judge = 0;
  for (tmp = 1; tmp <= 4; tmp++)
    if (a[tmp] == 'X') break;
  switch (tmp) {
    case 1:
      a[1] = a[2];
      a[2] = 'X';
      break;
    case 2:
      a[2] = a[4];
      a[4] = 'X';
      break;
    case 3:
      a[3] = a[1];
      a[1] = 'X';
      break;
    case 4:
      a[4] = a[3];
      a[3] = 'X';
      break;
    default:
      break;
  }
  return judge;
}
int space;
int main() {
  scanf("%c%c%c%c%c%c%c%c%c%c%c", &a[1], &a[2], &space, &a[3], &a[4], &space,
        &b[1], &b[2], &space, &b[3], &b[4]);
  for (register int i = 1; i <= 16; i++)
    if (solve()) return puts("YES"), 0;
  puts("NO");
  return 0;
}
