#include <bits/stdc++.h>
using namespace std;
int main() {
  char a[5][4];
  string s[5] = {""};
  for (int i = 0; i < 4; i++) cin >> a[1][i];
  swap(a[1][2], a[1][3]);
  for (int i = 0; i < 4; i++)
    if (a[1][i] != 'X') s[1] += a[1][i];
  for (int i = 0; i < 4; i++) cin >> a[0][i];
  swap(a[0][2], a[0][3]);
  for (int i = 0; i < 4; i++)
    if (a[0][i] != 'X') s[0] += a[0][i];
  for (int j = 2; j < 5; j++) {
    for (int i = 0; i < 3; i++) {
      s[j] += s[j - 1][(i + 1) % 3];
    }
  }
  int u = 0;
  for (int i = 1; i < 5; i++) {
    if (s[0] == s[i]) u++;
  }
  (u) ? cout << "YES\n" : cout << "NO\n";
}
