#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  string a[2], b[2];
  int i, j;
  cin >> a[0] >> a[1] >> b[0] >> b[1];
  string s1, s2;
  if (a[0][0] != 'X') s1 += a[0][0];
  if (a[0][1] != 'X') s1 += a[0][1];
  if (a[1][1] != 'X') s1 += a[1][1];
  if (a[1][0] != 'X') s1 += a[1][0];
  if (b[0][0] != 'X') s2 += b[0][0];
  if (b[0][1] != 'X') s2 += b[0][1];
  if (b[1][1] != 'X') s2 += b[1][1];
  if (b[1][0] != 'X') s2 += b[1][0];
  s1 += s1;
  s2 += s2;
  for (i = 0; i < 6; i++)
    if (s2[i] == s1[0]) break;
  if (s1[1] != s2[i + 1] or s1[2] != s2[i + 2])
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
