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