#include <bits/stdc++.h>
using namespace std;
char str1[3][3], str2[3][3];
char ans1[4], ans2[4];
int main() {
  while (~scanf("%s", str1[0])) {
    int h = 0, s = 0;
    scanf("%s", str1[1]);
    scanf("%s", str2[0]);
    scanf("%s", str2[1]);
    for (int i = 0; i < 2; i++) {
      if (i == 0) {
        for (int j = 0; j < 2; j++) {
          if (str1[i][j] != 'X') ans1[h++] = str1[i][j];
        }
      } else {
        for (int j = 1; j >= 0; j--) {
          if (str1[i][j] != 'X') ans1[h++] = str1[i][j];
        }
      }
    }
    for (int i = 0; i < 2; i++) {
      if (i == 0) {
        for (int j = 0; j < 2; j++) {
          if (str2[i][j] != 'X') ans2[s++] = str2[i][j];
        }
      } else {
        for (int j = 1; j >= 0; j--) {
          if (str2[i][j] != 'X') ans2[s++] = str2[i][j];
        }
      }
    }
    int n = 12;
    int flag = 1;
    while (n--) {
      if (ans1[0] == ans2[0] && ans1[1] == ans2[1] && ans1[2] == ans2[2]) {
        flag = 0;
        puts("YES");
        break;
      } else {
        char m = ans2[0];
        for (int i = 0; i < 2; i++) {
          ans2[i] = ans2[i + 1];
        }
        ans2[2] = m;
      }
    }
    if (flag) puts("NO");
  }
  return 0;
}
