#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1000009;
const double esp = 1e-6;
int main() {
  int ans = 0, book;
  char a[6], b[6];
  scanf("%s%s%s%s", a, a + 2, b, b + 2);
  for (int i = 0; i < 4; i++)
    if (a[i] == 'X') book = i;
  for (int i = 1; i <= 13; i++) {
    if (!strcmp(a, b)) {
      ans = 1;
      break;
    }
    if (book == 0)
      swap(a[0], a[2]), book = 2;
    else if (book == 1)
      swap(a[0], a[1]), book = 0;
    else if (book == 2)
      swap(a[2], a[3]), book = 3;
    else if (book == 3)
      swap(a[3], a[1]), book = 1;
  }
  if (ans)
    printf("YES\n");
  else
    printf("NO\n");
}
