#include <bits/stdc++.h>
using namespace std;
void read() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
string a1, a2, b1, b2;
void check() {
  if (a1[0] == 'X')
    swap(a1[0], a1[1]);
  else if (a1[1] == 'X')
    swap(a1[1], a2[1]);
  else if (a2[1] == 'X')
    swap(a2[1], a2[0]);
  else if (a2[0] == 'X')
    swap(a2[0], a1[0]);
}
void solve() {
  cin >> a1 >> a2 >> b1 >> b2;
  for (int i = 0; i < 65; ++i) {
    check();
    if (a1 == b1 && a2 == b2) {
      cout << "YES";
      return;
    }
  }
  cout << "NO";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int T = 1;
  while (T--) {
    solve();
    cout << '\n';
  }
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
}
