#include <bits/stdc++.h>
int main() {
  char bessie[4];
  char elsie[4];
  int a_bessie, a_elsie;
  char next_bessie, next_elsie;
  scanf("%c%c ", &bessie[0], &bessie[1]);
  scanf("%c%c ", &bessie[3], &bessie[2]);
  scanf("%c%c ", &elsie[0], &elsie[1]);
  scanf("%c%c", &elsie[3], &elsie[2]);
  for (int i = 0; i < 4; i++)
    if (bessie[i] == 'A') {
      a_bessie = i;
      break;
    }
  for (int i = 1; i < 4; i++) {
    int j = (a_bessie + i) % 4;
    if (bessie[j] != 'X') {
      next_bessie = bessie[j];
      break;
    }
  }
  for (int i = 0; i < 4; i++)
    if (elsie[i] == 'A') {
      a_elsie = i;
      break;
    }
  for (int i = 1; i < 4; i++) {
    int j = (a_elsie + i) % 4;
    if (elsie[j] != 'X') {
      next_elsie = elsie[j];
      break;
    }
  }
  if (next_elsie == next_bessie)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
