#include <bits/stdc++.h>
using namespace std;
const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
char a[2][2][2];
string b[2];
int x[4] = {0, 0, 1, 1};
int y[4] = {0, 1, 1, 0};
int main() {
  ios_base::sync_with_stdio(0);
  for (int t = 0; t < 2; ++t) {
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < 2; ++j) {
        cin >> a[t][i][j];
      }
    }
  }
  for (int t = 0; t < 2; ++t) {
    int st = -1;
    for (int i = 0; i < 4; ++i) {
      if (a[t][x[i]][y[i]] == 'A') {
        st = i;
        break;
      }
    }
    for (int i = 0; i < 4; ++i) {
      char tmp = a[t][x[(st + i) % 4]][y[(st + i) % 4]];
      if (tmp != 'X') {
        b[t].push_back(tmp);
      }
    }
  }
  cout << (b[0] == b[1] ? "YES" : "NO") << endl;
  return 0;
}
