#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  char a[4];
  char b[4];
  char x;
  int f = 0;
  int r = 0;
  for (int i = 0; i < 4; i++) {
    cin >> x;
    if (x != 'X') {
      a[r] = x;
      r++;
    } else {
      if (i < 2) f = 1;
    }
  }
  if (f) {
    char t = a[1];
    a[1] = a[2];
    a[2] = t;
    f = 0;
  }
  r = 0;
  for (int i = 0; i < 4; i++) {
    cin >> x;
    if (x != 'X') {
      b[r] = x;
      r++;
    } else {
      if (i < 2) f = 1;
    }
  }
  if (f) {
    char t = b[1];
    b[1] = b[2];
    b[2] = t;
  }
  int err = 0;
  int j = 0;
  for (int i = 0; i < 3; i++) {
    if (!i) {
      while (a[i] != b[j]) {
        j++;
      }
    } else {
      if (a[i] != b[j]) {
        err = 1;
        break;
      }
    }
    j = (j + 1) % 3;
  }
  if (!err) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
