#include <bits/stdc++.h>
using namespace std;
string scan_square() {
  string t1, t2;
  cin >> t1 >> t2;
  reverse(t2.begin(), t2.end());
  return t1 + t2;
}
void gen(string a, string b, int depth) {
  if (a == b) {
    puts("YES");
    exit(0);
  }
  if (depth == 20) return;
  int pos = a.find('X');
  int nxt = (pos + 1) % 4;
  swap(a[pos], a[nxt]);
  gen(a, b, depth + 1);
  swap(a[pos], a[nxt]);
  int prv = (pos + 3) % 4;
  swap(a[pos], a[prv]);
  gen(a, b, depth + 1);
  swap(a[pos], a[prv]);
}
void solve() {
  string a = scan_square();
  string b = scan_square();
  gen(a, b, 0);
  puts("NO");
}
int main() {
  solve();
  0;
  return 0;
}
