#include <bits/stdc++.h>
const int N = 1e5 + 3;
const int inf = 1e9;
using namespace std;
bool solve() {
  char s[5];
  string s1, s2;
  scanf("%s", s);
  for (int j = 0; j < 2; ++j)
    if (s[j] != 'X') s1 += s[j];
  scanf("%s", s);
  for (int j = 1; j >= 0; --j)
    if (s[j] != 'X') s1 += s[j];
  scanf("%s", s);
  for (int j = 0; j < 2; ++j)
    if (s[j] != 'X') s2 += s[j];
  scanf("%s", s);
  for (int j = 1; j >= 0; --j)
    if (s[j] != 'X') s2 += s[j];
  for (int i = 0; i < 10; ++i) {
    swap(s1[2], s1[1]);
    swap(s1[0], s1[1]);
    if (s1 == s2) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return false;
}
int main() {
  solve();
  return 0;
}
