#include <bits/stdc++.h>
using namespace std;
char A[2][2];
char B[2][2];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  for (int i = 0; i < int(2); ++i) {
    for (int j = 0; j < int(2); ++j) cin >> A[i][j];
  }
  for (int i = 0; i < int(2); ++i) {
    for (int j = 0; j < int(2); ++j) cin >> B[i][j];
  }
  string s1 = "A";
  string s2 = "A";
  if (A[0][0] == 'A') {
    s1 += A[0][1];
    s1 += A[1][1];
    s1 += A[1][0];
  } else if (A[0][1] == 'A') {
    s1 += A[1][1];
    s1 += A[1][0];
    s1 += A[0][0];
  } else if (A[1][1] == 'A') {
    s1 += A[1][0];
    s1 += A[0][0];
    s1 += A[0][1];
  } else if (A[1][0] == 'A') {
    s1 += A[0][0];
    s1 += A[0][1];
    s1 += A[1][1];
  }
  if (B[0][0] == 'A') {
    s2 += B[0][1];
    s2 += B[1][1];
    s2 += B[1][0];
  } else if (B[0][1] == 'A') {
    s2 += B[1][1];
    s2 += B[1][0];
    s2 += B[0][0];
  } else if (B[1][1] == 'A') {
    s2 += B[1][0];
    s2 += B[0][0];
    s2 += B[0][1];
  } else if (B[1][0] == 'A') {
    s2 += B[0][0];
    s2 += B[0][1];
    s2 += B[1][1];
  }
  string t1 = "";
  string t2 = "";
  for (auto &ch : s1) {
    if (ch != 'X') t1 += ch;
  }
  for (auto &ch : s2) {
    if (ch != 'X') t2 += ch;
  }
  cout << (t1 == t2 ? "YES" : "NO") << '\n';
  return 0;
}
