#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  bool ans = true;
  char A[4], B[4];
  cin >> A[0] >> A[1] >> A[3] >> A[2];
  cin >> B[0] >> B[1] >> B[3] >> B[2];
  for (int i = 0; i < 4; i++)
    if (A[i] == 'A') a = i;
  for (int i = 0; i < 4; i++)
    if (B[i] == 'A') b = i;
  for (int i = 0; i < 3; i++) {
    if (A[(a + i) % 4] == 'X') a++;
    if (B[(b + i) % 4] == 'X') b++;
    if (A[(a + i) % 4] != B[(b + i) % 4]) ans = false;
  }
  cout << (ans ? "YES" : "NO") << endl;
}
