#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int main() {
  char c[3][3], cc[3][3];
  char s[3][3];
  int ind1, ind2;
  int ii = 0;
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) {
      cin >> c[i][j];
      cc[i][j] = c[i][j];
    }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) {
      cin >> s[i][j];
    }
  for (ii = 0; ii < 60; ii++) {
    int t = 0;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        if (c[i][j] == 'X') {
          ind1 = i;
          ind2 = j;
        }
      }
    }
    if (ind1 == 0 && ind2 == 0) swap(c[0][0], c[1][0]);
    if (ind1 == 0 && ind2 == 1) swap(c[0][1], c[0][0]);
    if (ind1 == 1 && ind2 == 0) swap(c[1][0], c[1][1]);
    if (ind1 == 1 && ind2 == 1) swap(c[1][1], c[0][1]);
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) {
        if (s[i][j] != c[i][j]) {
          t = 1;
          break;
        }
      }
    if (t == 0) {
      cout << "YES" << endl;
      return 0;
    }
  }
  for (ii = 0; ii < 60; ii++) {
    int t = 0;
    for (int i = 0; i < 2; i++) {
      for (int j = 0; j < 2; j++) {
        if (cc[i][j] == 'X') {
          ind1 = i;
          ind2 = j;
        }
      }
    }
    if (ind1 == 0 && ind2 == 0) swap(c[0][0], c[0][1]);
    if (ind1 == 0 && ind2 == 1) swap(c[0][1], c[1][1]);
    if (ind1 == 1 && ind2 == 0) swap(c[1][0], c[0][0]);
    if (ind1 == 1 && ind2 == 1) swap(c[1][1], c[1][0]);
    for (int i = 0; i < 2; i++)
      for (int j = 0; j < 2; j++) {
        if (s[i][j] != c[i][j]) {
          t = 1;
          break;
        }
      }
    if (t == 0) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
