#include <bits/stdc++.h>
using namespace std;
const int maxN = 2e5;
vector<int> a(maxN);
vector<int> b(6);
string get(char ch) { return ch != 'X' ? string{ch} : ""; }
void solve() {
  vector<string> a(2);
  vector<string> b(2);
  cin >> a[0] >> a[1];
  cin >> b[0] >> b[1];
  string s1 = "" + get(a[0][0]) + get(a[0][1]) + get(a[1][1]) + get(a[1][0]);
  string s2 = "" + get(b[0][0]) + get(b[0][1]) + get(b[1][1]) + get(b[1][0]);
  int j = 0;
  for (int i = 0; i < 3; i++) {
    if (s2[i] == s1[0]) {
      while (j < 3) {
        if (s2[(i + j) % 3] != s1[j]) {
          cout << "NO"
               << "\n";
          return;
        }
        j++;
      }
      break;
    }
  }
  cout << "YES"
       << "\n";
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  while (t--) solve();
}
