#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b, c, d;
  cin >> a >> b >> c >> d;
  swap(b[0], b[1]);
  swap(d[0], d[1]);
  a += b;
  c += d;
  string tempa, tempb;
  for (long long int i = 0; i < a.length(); ++i) {
    if (a[i] != 'X') tempa += a[i];
  }
  for (long long int i = 0; i < c.length(); ++i) {
    if (c[i] != 'X') tempb += c[i];
  }
  tempa += tempa;
  if (tempa.find(tempb) != string::npos) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
