#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int N = 1000;
int n, k, m;
string s[N];
string x, y;
int main() {
  ios_base::sync_with_stdio(0);
  cout.tie(0);
  cin.tie(0);
  for (int i = 0; i < 4; i++) cin >> s[i];
  if (s[0][0] != 'X') x += s[0][0];
  if (s[0][1] != 'X') x += s[0][1];
  if (s[1][1] != 'X') x += s[1][1];
  if (s[1][0] != 'X') x += s[1][0];
  if (s[2][0] != 'X') y += s[2][0];
  if (s[2][1] != 'X') y += s[2][1];
  if (s[3][1] != 'X') y += s[3][1];
  if (s[3][0] != 'X') y += s[3][0];
  int i = 0;
  int j = 0;
  while (x[i] != 'A') i++;
  while (y[j] != 'A') j++;
  for (int k = 1; k <= 3; k++) {
    if (x[i] != y[j]) {
      cout << "NO";
      return 0;
    }
    i++;
    j++;
    if (i > 2) i = 0;
    if (j > 2) j = 0;
  }
  cout << "YES";
  return 0;
}
