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