#include <bits/stdc++.h>
using namespace std;
const int maxn = 500000 + 200;
int a[3], b[10];
char s[2][5], t[2][5];
int X[] = {0, 0, 1, 1, 0};
int Y[] = {0, 1, 1, 0, 0};
int main() {
  cin >> s[0];
  cin >> s[1];
  cin >> t[0];
  cin >> t[1];
  int cnt = 0;
  for (int first, j = 0, second; j < 4; j++) {
    first = X[j], second = Y[j];
    if (s[first][second] != 'X') a[cnt++] = s[first][second];
    first = X[j], second = Y[j];
  }
  cnt = 0;
  for (int first, j = 0, second; j < 4; j++) {
    first = X[j], second = Y[j];
    if (t[first][second] != 'X') b[cnt++] = t[first][second];
  }
  int j = 0;
  int ok = 0;
  do {
    ok = 1;
    for (int i = 0; i < 3; i++)
      if (a[i] != b[(i + j) % 3]) {
        ok = 0;
        break;
      }
    j++;
  } while (!ok && j < 3);
  if (ok)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
