#include <bits/stdc++.h>
using namespace std;
int main() {
  string a1, b1;
  cin >> a1 >> b1;
  string a2, b2;
  cin >> a2 >> b2;
  string a, b;
  for (int i = 0; i < 2; ++i)
    if (a1[i] != 'X') a += a1[i];
  for (int i = 1; i >= 0; --i)
    if (b1[i] != 'X') a += b1[i];
  for (int i = 0; i < 2; ++i)
    if (a2[i] != 'X') b += a2[i];
  for (int i = 1; i >= 0; --i)
    if (b2[i] != 'X') b += b2[i];
  bool ok = false;
  for (int i = 0; !ok && i < 3; ++i) {
    string c;
    for (int j = 0; j < 3; ++j) c += a[(i + j) % 3];
    if (c == b) ok = true;
  }
  cout << (ok ? "YES" : "NO") << endl;
  return 0;
}
