#include <bits/stdc++.h>
using namespace std;
template <typename T>
class heap : public priority_queue<T, vector<T>, greater<T> > {};
int main(void) {
  char s[4][10];
  for (int i = 0; i < 4; ++i) {
    scanf("%s\n", s[i]);
  }
  string a = string(s[0]);
  a += s[1][1];
  a += s[1][0];
  string x = "";
  int i = 0;
  while (x.size() != 3) {
    if (a[i] == 'X' || (x.size() == 0 && a[i] != 'A')) {
      i = (i + 1) % 4;
      continue;
    }
    x += a[i];
    i = (i + 1) % 4;
  }
  string b = string(s[2]);
  b += s[3][1];
  b += s[3][0];
  string y = "";
  i = 0;
  while (y.size() != 3) {
    if (b[i] == 'X' || (y.size() == 0 && b[i] != 'A')) {
      i = (i + 1) % 4;
      continue;
    }
    y += b[i];
    i = (i + 1) % 4;
  }
  if (x == y)
    puts("YES");
  else
    puts("NO");
}
