#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[10][10];
  char b[10][10];
  vector<char> v, l;
  long long int i, count = 0, j;
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      cin >> a[i][j];
    }
  }
  v.push_back(a[0][0]);
  v.push_back(a[0][1]);
  v.push_back(a[1][1]);
  v.push_back(a[1][0]);
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      cin >> b[i][j];
    }
  }
  l.push_back(b[0][0]);
  l.push_back(b[0][1]);
  l.push_back(b[1][1]);
  l.push_back(b[1][0]);
  int flag = 0;
  v.erase(remove(v.begin(), v.end(), 'X'), v.end());
  l.erase(remove(l.begin(), l.end(), 'X'), l.end());
  for (i = 0; i < 3; i++) {
    if (equal(v.begin(), v.end(), l.begin())) {
      flag = 1;
      break;
    } else {
      vector<char>::iterator k = v.begin() + 2;
      char la = *k;
      v.insert(v.begin(), *k);
      v.erase(v.begin() + 3);
    }
  }
  if (flag)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
