#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  string a1, a2, b1, b2;
  cin >> a1 >> a2 >> b1 >> b2;
  swap(a2[0], a2[1]);
  swap(b2[0], b2[1]);
  a1 += a2;
  b1 += b2;
  a1.erase(a1.find('X'), 1);
  b1.erase(b1.find('X'), 1);
  cout << ((b1 + b1).find(a1) == string::npos ? "NO" : "YES");
  return 0;
}
