#include <bits/stdc++.h>
using namespace std;
char c[5][3];
int main() {
  for (int i = 1; i <= 4; i++)
    for (int j = 1; j <= 2; j++) cin >> c[i][j];
  string a, b;
  if (c[1][1] != 'X') a += c[1][1];
  if (c[1][2] != 'X') a += c[1][2];
  if (c[2][2] != 'X') a += c[2][2];
  if (c[2][1] != 'X') a += c[2][1];
  if (c[3][1] != 'X') b += c[3][1];
  if (c[3][2] != 'X') b += c[3][2];
  if (c[4][2] != 'X') b += c[4][2];
  if (c[4][1] != 'X') b += c[4][1];
  for (int i = 0; i < b.size(); i++) {
    if (a == b) {
      puts("YES");
      return 0;
    }
    for (int j = 1; j < b.size(); j++) swap(b[j], b[j - 1]);
    if (a == b) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
  return 0;
}
