#include <bits/stdc++.h>
using namespace std;
char tab1[2][2], tab2[2][2];
vector<char> vec1, vec2;
map<char, char> mp;
int main() {
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> tab1[i][j];
    }
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> tab2[i][j];
    }
  }
  for (int i = 0; i < 2; i++) {
    if (tab1[0][i] != 'X') vec1.push_back(tab1[0][i]);
    if (tab2[0][i] != 'X') vec2.push_back(tab2[0][i]);
  }
  for (int i = 1; i > -1; i--) {
    if (tab1[1][i] != 'X') vec1.push_back(tab1[1][i]);
    if (tab2[1][i] != 'X') vec2.push_back(tab2[1][i]);
  }
  vec1.push_back(vec1[0]);
  vec2.push_back(vec2[0]);
  for (int i = 0; i < 3; i++) {
    mp[vec1[i]] = vec1[i + 1];
  }
  for (int i = 0; i < 3; i++) {
    if (mp[vec2[i]] != vec2[i + 1]) {
      cout << "NO";
      return 0;
    }
  }
  cout << "YES";
  return 0;
}
