#include <bits/stdc++.h>
using namespace std;
int main() {
  char r, a[4], b[4];
  cin >> a[0];
  cin >> a[1];
  cin >> a[3];
  cin >> a[2];
  cin >> b[0];
  cin >> b[1];
  cin >> b[3];
  cin >> b[2];
  while (a[0] != 'A') {
    r = a[0];
    a[0] = a[1];
    a[1] = a[2];
    a[2] = a[3];
    a[3] = r;
  }
  if (a[1] == 'X') {
    a[1] = a[2];
    a[2] = a[3];
    a[3] = 'X';
  }
  if (a[2] == 'X') {
    a[2] = a[3];
    a[3] = 'X';
  }
  while (b[0] != 'A') {
    r = b[0];
    b[0] = b[1];
    b[1] = b[2];
    b[2] = b[3];
    b[3] = r;
  }
  if (b[1] == 'X') {
    b[1] = b[2];
    b[2] = b[3];
    b[3] = 'X';
  }
  if (b[2] == 'X') {
    b[2] = b[3];
    b[3] = 'X';
  }
  if (a[2] == b[2]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
