#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s, s1, str1, str2;
  char a[2][2], b[2][2];
  for (long long i = 0; i < 2; i++)
    for (long long j = 0; j < 2; j++) cin >> a[i][j];
  for (long long i = 0; i < 2; i++)
    for (long long j = 0; j < 2; j++) cin >> b[i][j];
  if (a[0][0] == 'A') {
    s.push_back(a[0][0]), s.push_back(a[0][1]), s.push_back(a[1][1]),
        s.push_back(a[1][0]);
  } else if (a[0][1] == 'A') {
    s.push_back(a[0][1]), s.push_back(a[1][1]), s.push_back(a[1][0]),
        s.push_back(a[0][0]);
  } else if (a[1][1] == 'A') {
    s.push_back(a[1][1]), s.push_back(a[1][0]), s.push_back(a[0][0]),
        s.push_back(a[0][1]);
  } else {
    s.push_back(a[1][0]), s.push_back(a[0][0]), s.push_back(a[0][1]),
        s.push_back(a[1][1]);
  }
  if (b[0][0] == 'A') {
    s1.push_back(b[0][0]), s1.push_back(b[0][1]), s1.push_back(b[1][1]),
        s1.push_back(b[1][0]);
  } else if (b[0][1] == 'A') {
    s1.push_back(b[0][1]), s1.push_back(b[1][1]), s1.push_back(b[1][0]),
        s1.push_back(b[0][0]);
  } else if (b[1][1] == 'A') {
    s1.push_back(b[1][1]), s1.push_back(b[1][0]), s1.push_back(b[0][0]),
        s1.push_back(b[0][1]);
  } else {
    s1.push_back(b[1][0]), s1.push_back(b[0][0]), s1.push_back(b[0][1]),
        s1.push_back(b[1][1]);
  }
  for (long long i = 0; i < 4; i++) {
    if (s[i] != 'X') str1.push_back(s[i]);
    if (s1[i] != 'X') str2.push_back(s1[i]);
  }
  if (str1 == str2)
    cout << "YES\n";
  else
    cout << "NO\n";
}
