#include <bits/stdc++.h>
using namespace std;
int main() {
  int x, y;
  vector<vector<char>> a(2, vector<char>(2));
  vector<vector<char>> b(2, vector<char>(2));
  for (int i = 0; i < 2; i++) {
    string l;
    cin >> l;
    for (int j = 0; j < 2; j++) {
      if (l[j] == 'X') {
        x = i;
        y = j;
      }
      a[i][j] = l[j];
    }
  }
  for (int i = 0; i < 2; i++) {
    string l;
    cin >> l;
    for (int j = 0; j < 2; j++) {
      b[i][j] = l[j];
    }
  }
  for (int d = 0; d < 13; d++) {
    bool ok = false;
    if (x == 0 && y == 0) {
      a[x][y] = a[x + 1][y];
      a[x + 1][y] = 'X';
      x++;
    } else if (x == 1 && y == 0) {
      a[x][y] = a[x][y + 1];
      a[x][y + 1] = 'X';
      y++;
    } else if (x == 0 && y == 1) {
      a[x][y] = a[x][y - 1];
      a[x][y - 1] = 'X';
      y--;
    } else if (x == 1 && y == 1) {
      a[x][y] = a[x - 1][y];
      a[x - 1][y] = 'X';
      x--;
    }
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        if (a[i][j] != b[i][j]) {
          ok = true;
          break;
        }
      }
      if (ok) {
        break;
      }
    }
    if (!ok) {
      cout << "YES";
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
