#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-11;
const long double pi = acos(-1.0);
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<char> v, u;
  for (int i = 0; i < 2; i++) {
    string s;
    cin >> s;
    if (i == 0) {
      for (int j = 0; j < 2; j++) {
        if (s[j] != 'X') v.push_back(s[j]);
      }
    } else {
      for (int j = 2 - 1; j >= 0; j--) {
        if (s[j] != 'X') v.push_back(s[j]);
      }
    }
  }
  for (int i = 0; i < 2; i++) {
    string t;
    cin >> t;
    if (i == 0) {
      for (int j = 0; j < 2; j++) {
        if (t[j] != 'X') u.push_back(t[j]);
      }
    } else {
      for (int j = 2 - 1; j >= 0; j--) {
        if (t[j] != 'X') u.push_back(t[j]);
      }
    }
  }
  string ans = "NO";
  for (int j = 0; j < 3; j++) {
    if (u == v) ans = "YES";
    u.push_back(u[0]);
    u.erase(u.begin());
  }
  cout << ans << endl;
  return 0;
}
