#include <bits/stdc++.h>
using namespace std;
string strA, strB, strAux;
char aux;
int main() {
  cin >> strA;
  cin >> strAux;
  aux = strAux[1];
  strAux[1] = strAux[0];
  strAux[0] = aux;
  strA += strAux;
  cin >> strB;
  cin >> strAux;
  aux = strAux[1];
  strAux[1] = strAux[0];
  strAux[0] = aux;
  strB += strAux;
  strA.erase(strA.find("X"), 1);
  strB.erase(strB.find("X"), 1);
  int posA = strA.find("A");
  int posB = strB.find("A");
  bool flag = true;
  for (int i = 0; i < 3; i++) {
    if (strA[posA] != strB[posB]) {
      flag = false;
      break;
    }
    posA++;
    if (posA == 3) {
      posA = 0;
    }
    posB++;
    if (posB == 3) {
      posB = 0;
    }
  }
  if (flag) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
