#include <bits/stdc++.h>
using namespace std;
const long long inf = 4e18;
const long long maxn = 2e5 + 10;
const long long mod = 1e9 + 7;
string s[2];
deque<char> Get() {
  cin >> s[0] >> s[1];
  deque<char> v1, v2;
  v1.clear();
  v2.clear();
  v1.push_back(s[0][0]);
  v1.push_back(s[0][1]);
  v1.push_back(s[1][1]);
  v1.push_back(s[1][0]);
  bool start = 0;
  for (int i = 0; i < int(8); i++) {
    if (start && v1[i % 4] != 'X') v2.push_back(v1[i % 4]);
    start ^= (v1[i % 4] == 'X');
  }
  while (v2.front() != 'A') {
    v2.push_back(v2.front());
    v2.pop_front();
  }
  return v2;
}
int main() { cout << (Get() == Get() ? "YES" : "NO"); }
