#include <bits/stdc++.h>
int main(void) {
  char a[3], b[3], c[3], d[3], a1[7], b1[4], c1[7];
  scanf("%s", a);
  scanf("%s", b);
  scanf("%s", c);
  scanf("%s", d);
  int k = 0;
  if (a[0] != 'X') {
    a1[0] = a[0];
    a1[3] = a[0];
    k++;
  }
  if (a[1] != 'X') {
    a1[k] = a[1];
    a1[k + 3] = a[1];
    k++;
  }
  if (b[1] != 'X') {
    a1[k] = b[1];
    a1[k + 3] = b[1];
    k++;
  }
  if (b[0] != 'X') {
    a1[k] = b[0];
    a1[k + 3] = b[0];
    k++;
  }
  a1[6] = '\0';
  strcpy(c1, a1);
  k = 0;
  if (c[0] != 'X') {
    b1[0] = c[0];
    b1[3] = c[0];
    k++;
  }
  if (c[1] != 'X') {
    b1[k] = c[1];
    b1[k + 3] = c[1];
    k++;
  }
  if (d[1] != 'X') {
    b1[k] = d[1];
    b1[k + 3] = d[1];
    k++;
  }
  if (d[0] != 'X') {
    b1[k] = d[0];
    b1[k + 3] = d[0];
    k++;
  }
  a1[6] = '\0';
  b1[3] = '\0';
  if (strstr(c1, b1) != NULL) {
    printf("YES");
  } else {
    printf("NO");
  }
  return 0;
}
