#include <bits/stdc++.h>
using namespace std;
int main() {
  char ara[4][3], tem;
  int flag = 0, p, q, i, j;
  for (int i = 0; i < 4; i++) scanf(" %s", ara[i]);
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++)
      if (ara[i][j] == 'X') break;
    if (ara[i][j] == 'X') break;
  }
  for (int k = 0; k < 12; k++) {
    if (strcmp(ara[0], ara[2]) == 0 && strcmp(ara[1], ara[3]) == 0) flag = 1;
    p = i, q = j;
    if (k % 2 == 0)
      i = (i + 1) % 2;
    else
      j = (j + 1) % 2;
    tem = ara[i][j], ara[i][j] = ara[p][q], ara[p][q] = tem;
  }
  if (flag == 1)
    cout << "YES";
  else
    cout << "NO";
}
