#include <bits/stdc++.h>
using namespace std;
int main() {
  char board[4][4];
  for (int i = 0; i < 4; i++) scanf("%s", board[i]);
  board[0][2] = board[1][1];
  board[0][3] = board[1][0];
  board[2][2] = board[3][1];
  board[2][3] = board[3][0];
  int a = 0, b = 0;
  while (board[0][a] != 'A') a++;
  while (board[2][b] != 'A') b++;
  a = (a + 1) % 4;
  b = (b + 1) % 4;
  if (board[0][a] == 'X') a = (a + 1) % 4;
  if (board[2][b] == 'X') b = (b + 1) % 4;
  if (board[0][a] == board[2][b])
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
