#include <bits/stdc++.h>
using namespace std;
vector<int> v[50010];
unsigned int dp[50010][1024], c[1024], val[50010];
string s, S, t, T;
bool okay() {
  puts("YES");
  exit(0);
}
bool judge() {
  S = "";
  T = "";
  for (auto &i : s) {
    if (i != 'X') S += i;
  }
  for (auto &i : t) {
    if (i != 'X') T += i;
  }
  return S == T;
}
int main() {
  for (int i = 1; i <= 2; i++) {
    cin >> S;
    if (i == 2) swap(S[0], S[1]);
    s += S;
  }
  for (int i = 1; i <= 2; i++) {
    cin >> T;
    if (i == 2) swap(T[0], T[1]);
    t += T;
  }
  for (int i = 0; i < 4; i++) {
    S = s;
    s[0] = S[3];
    s[1] = S[0];
    s[2] = S[1];
    s[3] = S[2];
    if (judge()) okay();
  }
  puts("NO");
  return 0;
}
