#include <bits/stdc++.h>
using namespace std;
char a, b, c, d, e, f, g, h;
string s1 = "", s2 = "";
bool ok;
void cty() {
  char x = s2[0], y = s2[1], z = s2[2];
  s2 = "";
  s2 += y, s2 += z, s2 += x;
}
int main() {
  cin >> a >> b >> c >> d >> e >> f >> g >> h;
  if (a != 'X') s1 += a;
  if (b != 'X') s1 += b;
  if (d != 'X') s1 += d;
  if (c != 'X') s1 += c;
  if (e != 'X') s2 += e;
  if (f != 'X') s2 += f;
  if (h != 'X') s2 += h;
  if (g != 'X') s2 += g;
  if (s1 == s2) ok = 1;
  cty();
  if (s1 == s2) ok = 1;
  cty();
  if (s1 == s2) ok = 1;
  printf(ok ? "YES\n" : "NO\n");
  return 0;
}
