#include <bits/stdc++.h>
using namespace std;
set<string> explr;
string dest;
bool solve(string cur) {
  if (cur == dest) return true;
  if (explr.count(cur)) return false;
  explr.insert(cur);
  int xrow, xcol;
  for (int i = 0; i < 4; i++)
    if (cur[i] == 'X') {
      xrow = i / 2;
      xcol = i % 2;
    }
  string next = cur;
  swap(next[xrow * 2], next[xrow * 2 + 1]);
  if (solve(next)) return true;
  next = cur;
  swap(next[xcol], next[2 + xcol]);
  if (solve(next)) return true;
  return false;
}
int main() {
  string ini, p;
  cin >> p;
  ini += p;
  cin >> p;
  ini += p;
  cin >> p;
  dest += p;
  cin >> p;
  dest += p;
  if (solve(ini))
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
