#include <bits/stdc++.h>
using namespace std;
string t;
char a[10][10];
string read() {
  bool f = 0;
  string s = t, k = t;
  s += a[0][0];
  s += a[0][1];
  s += a[1][1];
  s += a[1][0];
  s += s;
  for (int i = 0; i < 8; i++) {
    if (f && s[i] != 'X') {
      k += s[i];
      return k;
    }
    if (s[i] == 'A') f = 1;
  }
  return s;
}
int main() {
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) cin >> a[i][j];
  string s = read();
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) cin >> a[i][j];
  if (read() == s)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
