#include <bits/stdc++.h>
using namespace std;
int main() {
  string x[2];
  cin >> x[0] >> x[1];
  string res;
  string resA, resB;
  if (x[0][0] != 'X') {
    res.push_back(x[0][0]);
  }
  if (x[0][1] != 'X') {
    res.push_back(x[0][1]);
  }
  if (x[1][1] != 'X') {
    res.push_back(x[1][1]);
  }
  if (x[1][0] != 'X') {
    res.push_back(x[1][0]);
  }
  resA = res;
  res.clear();
  cin >> x[0] >> x[1];
  if (x[0][0] != 'X') {
    res.push_back(x[0][0]);
  }
  if (x[0][1] != 'X') {
    res.push_back(x[0][1]);
  }
  if (x[1][1] != 'X') {
    res.push_back(x[1][1]);
  }
  if (x[1][0] != 'X') {
    res.push_back(x[1][0]);
  }
  resB = res;
  int i1 = resA.find('A');
  int i2 = resB.find('A');
  for (int i = 0; i < 3; ++i) {
    if (resA[(i1 + i) % 3] != resB[(i2 + i) % 3]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
