#include <bits/stdc++.h>
using namespace std;
string A, B;
map<string, bool> vis;
bool ans;
void dfs(string A) {
  if (A == B) {
    ans = true;
    return;
  }
  if (vis.count(A)) return;
  vis[A] = true;
  for (int i = 0; i < 4; i++) {
    if (A[i] == 'X') {
      string tmp = A;
      swap(tmp[i], tmp[(i + 1) % 4]);
      dfs(tmp);
    }
  }
  for (int i = 0; i < 4; i++) {
    if (A[i] == 'X') {
      string tmp = A;
      swap(tmp[i], tmp[(i + 3) % 4]);
      dfs(tmp);
    }
  }
  return;
}
int main() {
  for (int i = 0; i < 2; i++) {
    string s;
    cin >> s;
    if (i) reverse(s.begin(), s.end());
    A += s;
  }
  for (int i = 0; i < 2; i++) {
    string s;
    cin >> s;
    if (i) reverse(s.begin(), s.end());
    B += s;
  }
  dfs(A);
  if (ans)
    puts("YES");
  else
    puts("NO");
  return 0;
}
