#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  string a, b, tem;
  for (int i = 0; i < 4; i++) {
    char c;
    cin >> c;
    if (c == 'X') continue;
    if (i < 2)
      a += c;
    else
      tem += c;
  }
  for (int i = tem.size() - 1; i >= 0; i--) a += tem[i];
  tem.clear();
  for (int i = 0; i < 4; i++) {
    char c;
    cin >> c;
    if (c == 'X') continue;
    if (i < 2)
      b += c;
    else
      tem += c;
  }
  for (int i = tem.size() - 1; i >= 0; i--) b += tem[i];
  int pos;
  for (int i = 0; i < 3; i++)
    if (b[i] == a[0]) pos = i;
  int i;
  for (i = 0; i < 3; i++, pos++)
    if (a[i] != b[pos % 3]) break;
  cout << (i < 3 ? "NO" : "YES");
  return 0;
}
