#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fll;
void fix(string &s) {
  if (s[1] == 'X')
    swap(s[1], s[0]);
  else if (s[2] == 'X')
    swap(s[0], s[2]);
  else if (s[3] == 'X') {
    swap(s[1], s[3]);
    swap(s[0], s[1]);
  }
}
int main() {
  string s1, s2, buff;
  cin >> s1 >> buff;
  s1 += buff;
  cin >> s2 >> buff;
  s2 += buff;
  fix(s1);
  fix(s2);
  bool ok = 0;
  for (int i = 0; i < 3; i++) {
    rotate(s1.begin() + 1, s1.begin() + 2, s1.begin() + 4);
    if (s1 == s2) ok = 1;
  }
  printf("%s\n", ok ? "YES" : "NO");
  return 0;
}
