#include <bits/stdc++.h>
const int MAX_N = (int)1e5 + 123;
const double eps = 1e-6;
const int inf = (int)1e9 + 123;
using namespace std;
map<string, bool> where;
string a, b;
void solve(string a, string b) {
  if (where[a + b]) return;
  where[a + b] = 1;
  for (int i = 0; i < 2; i++)
    if (a[i] == 'X') {
      swap(a[i], a[1 - i]);
      solve(a, b);
      swap(a[i], a[1 - i]);
      swap(a[i], b[i]);
      solve(a, b);
      swap(a[i], b[i]);
    }
  for (int i = 0; i < 2; i++)
    if (b[i] == 'X') {
      swap(b[i], b[1 - i]);
      solve(a, b);
      swap(b[i], b[1 - i]);
      swap(a[i], b[i]);
      solve(a, b);
      swap(a[i], b[i]);
    }
}
int main() {
  cin >> a >> b;
  solve(a, b);
  cin >> a >> b;
  if (where[a + b])
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
