#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 5e5 + 10;
void printY() {
  puts("YES");
  exit(0);
}
void printN() {
  puts("NO");
  exit(0);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s1, s2;
  cin >> s1 >> s2;
  reverse(s2.begin(), s2.end());
  string s = s1 + s2;
  cin >> s1 >> s2;
  reverse(s2.begin(), s2.end());
  string ss = s1 + s2;
  if (s == ss) {
    printY();
  }
  for (int i = 0; i < 4; i++) {
    if (s[i] == 'X') {
      int indx = i;
      string temp = s;
      map<string, int> mm;
      for (int j = (i + 1) % 4;; j = (j + 1) % 4) {
        swap(s[indx], s[j]);
        if (s == ss) printY();
        indx = j;
        if (mm.find(s) != mm.end()) break;
        mm[s] = 1;
      }
      s = temp;
      indx = i;
      mm.clear();
      for (int j = (i - 1 + 4) % 4;; j = (j - 1 + 4) % 4) {
        swap(s[indx], s[j]);
        if (s == ss) printY();
        indx = j;
        if (mm.find(s) != mm.end()) break;
        mm[s] = 1;
      }
      printN();
    }
  }
  return 0;
}
