#include <bits/stdc++.h>
using namespace std;
string flatten(vector<string> a) { return a[0] + a[1]; }
bool dfs(vector<string> src, string dest, map<string, int>& res) {
  string t = flatten(src);
  if (t == dest) return true;
  if (res[t] > 0) return false;
  res[t]++;
  int i, j, u, v;
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      if (src[i][j] == 'X') break;
    }
    if (j < 2 && src[i][j] == 'X') break;
  }
  int dx[4] = {0, -1, 0, 1};
  int dy[4] = {1, 0, -1, 0};
  for (int x = 0; x < 4; x++) {
    u = i + dx[x];
    v = j + dy[x];
    if (u >= 0 && u < 2 && v >= 0 && v < 2) {
      swap(src[i][j], src[u][v]);
      if (dfs(src, dest, res)) return true;
      swap(src[i][j], src[u][v]);
    }
  }
  return false;
}
int main() {
  vector<string> src, dest;
  map<string, int> res;
  string t;
  for (long long i = 0; i < 2; i++) {
    cin >> t;
    src.push_back(t);
  }
  for (long long i = 0; i < 2; i++) {
    cin >> t;
    dest.push_back(t);
  }
  cout << (dfs(src, flatten(dest), res) ? "YES" : "NO") << endl;
  return 0;
}
