#include <bits/stdc++.h>
using namespace std;
char a[5][5];
char last;
char first;
char safasfas[10000];
int main() {
  last = '#';
  first = last;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) cin >> a[i][j];
  for (int i = 0; i < 2; i++) {
    if (i == 0)
      for (int j = 0; j < 2; j++) {
        if (a[i][j] == 'X') continue;
        if (first == '#') first = a[i][j];
        safasfas[last] = a[i][j];
        last = a[i][j];
      }
    else
      for (int j = 1; j >= 0; j--) {
        if (a[i][j] == 'X') continue;
        if (first == '#') first = a[i][j];
        safasfas[last] = a[i][j];
        last = a[i][j];
      }
  }
  safasfas[last] = first;
  last = '#';
  first = last;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) cin >> a[i][j];
  for (int i = 0; i < 2; i++) {
    if (i == 0)
      for (int j = 0; j < 2; j++) {
        if (a[i][j] == 'X') continue;
        if (first == '#') first = a[i][j];
        if (last != '#' && safasfas[last] != a[i][j]) {
          cout << "NO\n";
          return 0;
        }
        last = a[i][j];
      }
    else
      for (int j = 1; j >= 0; j--) {
        if (a[i][j] == 'X') continue;
        if (first == '#') first = a[i][j];
        if (last != '#' && safasfas[last] != a[i][j]) {
          cout << "NO\n";
          return 0;
        }
        last = a[i][j];
      }
  }
  if (safasfas[last] != first) {
    {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
  return 0;
}
