#include <bits/stdc++.h>
char t1[2][2], t2[2][2];
bool cmp() {
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++)
      if (t1[i][j] != t2[i][j]) return false;
  return true;
}
void next() {
  if (t1[0][0] == 'X') {
    t1[0][0] = t1[1][0];
    t1[1][0] = 'X';
  } else if (t1[1][0] == 'X') {
    t1[1][0] = t1[1][1];
    t1[1][1] = 'X';
  } else if (t1[1][1] == 'X') {
    t1[1][1] = t1[0][1];
    t1[0][1] = 'X';
  } else if (t1[0][1] == 'X') {
    t1[0][1] = t1[0][0];
    t1[0][0] = 'X';
  }
}
int main() {
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) std::cin >> t1[i][j];
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) std::cin >> t2[i][j];
  for (int i = 0; i < 64; i++) {
    if (cmp()) {
      std::cout << "YES";
      return 0;
    }
    next();
  }
  std::cout << "NO";
}
