#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const double eps = (double)1e-8;
const int mod = (int)1000000007;
const int maxn = (int)1e5 + 5;
string st1, st2;
int str;
char s1[11][11], s2[11][11];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  st1 = "";
  st2 = "";
  for (int i = (1); i <= (2); i++)
    for (int j = (1); j <= (2); j++) {
      cin >> s1[i][j];
    }
  for (int i = (1); i <= (2); i++) {
    if (s1[1][i] != 'X') st1 += s1[1][i];
  }
  for (int i = (2); i >= (1); i--) {
    if (s1[2][i] != 'X') st1 += s1[2][i];
  }
  for (int i = (1); i <= (2); i++)
    for (int j = (1); j <= (2); j++) {
      cin >> s2[i][j];
    }
  for (int i = (1); i <= (2); i++) {
    if (s2[1][i] != 'X') st2 += s2[1][i];
  }
  for (int i = (2); i >= (1); i--) {
    if (s2[2][i] != 'X') st2 += s2[2][i];
  }
  st2 = st2 + st2;
  str = 0;
  for (int i = (0); i <= (2); i++)
    if (st1[0] == st2[i]) {
      str = i;
      break;
    }
  for (int i = (str); i <= (str + 2); i++)
    if (st1[i - str] != st2[i]) {
      cout << "NO";
      return 0;
    }
  cout << "YES";
  return 0;
}
