#include <bits/stdc++.h>
using namespace std;
long double esp = 1e-11;
const double PI = acos(-1.0);
const long long int INF = 0x3f3f3f3f;
const long long int MOD = 1000000007ll;
const int maxn = 200010;
char s1[3][3], s2[3][3];
int main() {
  scanf("%s%s%s%s", s1[0], s1[1], s2[0], s2[1]);
  while (s1[0][0] != 'A') {
    char t;
    t = s1[0][0];
    s1[0][0] = s1[1][0];
    s1[1][0] = s1[1][1];
    s1[1][1] = s1[0][1];
    s1[0][1] = t;
  }
  while (s2[0][0] != 'A') {
    char t;
    t = s2[0][0];
    s2[0][0] = s2[1][0];
    s2[1][0] = s2[1][1];
    s2[1][1] = s2[0][1];
    s2[0][1] = t;
  }
  char t = 0;
  if (s1[0][1] != 'X')
    t = s1[0][1];
  else
    t = s1[1][1];
  char t1 = 0;
  if (s2[0][1] != 'X')
    t1 = s2[0][1];
  else
    t1 = s2[1][1];
  if (t == t1)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
