#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.sync_with_stdio(false);
  string a, b, c, d;
  cin >> a >> b >> c >> d;
  string s;
  if (a[0] != 'X') s += a[0];
  if (a[1] != 'X') s += a[1];
  if (b[1] != 'X') s += b[1];
  if (b[0] != 'X') s += b[0];
  string t;
  if (c[0] != 'X') t += c[0];
  if (c[1] != 'X') t += c[1];
  if (d[1] != 'X') t += d[1];
  if (d[0] != 'X') t += d[0];
  for (int i = 0; i < 3; i++) {
    if (s == t) {
      cout << "YES\n";
      return 0;
    }
    char mlc = t[0];
    t.erase(t.begin());
    t += mlc;
  }
  cout << "NO\n";
  return 0;
}
