#include <bits/stdc++.h>
using namespace std;
inline string read() {
  string ret = "";
  int x = 0, f = 1;
  char ch = getchar();
  while (!isalpha(ch)) {
    ch = getchar();
  }
  if (isalpha(ch)) {
    ch == 'X' ? ret = "" : ret += ch;
  }
  return ret;
}
string a[3][3];
string now[4], qwq;
int main() {
  a[1][1] = read();
  a[1][2] = read();
  a[2][1] = read();
  a[2][2] = read();
  now[0] = a[1][1] + a[1][2] + a[2][2] + a[2][1];
  now[1] = a[1][2] + a[2][2] + a[2][1] + a[1][1];
  now[2] = a[2][2] + a[2][1] + a[1][1] + a[1][2];
  now[3] = a[2][1] + a[1][1] + a[1][2] + a[2][2];
  a[1][1] = read();
  a[1][2] = read();
  a[2][1] = read();
  a[2][2] = read();
  qwq = a[1][1] + a[1][2] + a[2][2] + a[2][1];
  printf((now[0] == qwq) || (now[1] == qwq) || (now[2] == qwq) ||
                 (now[3] == qwq)
             ? "YES"
             : "NO");
  return 0;
}
