#include <bits/stdc++.h>
using namespace std;
vector<char> v;
vector<char> vv;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  char s[3][3], ss[3][3];
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) cin >> s[i][j];
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) cin >> ss[i][j];
  if (s[0][0] != 'X') v.push_back(s[0][0]);
  if (s[0][1] != 'X') v.push_back(s[0][1]);
  if (s[1][1] != 'X') v.push_back(s[1][1]);
  if (s[1][0] != 'X') v.push_back(s[1][0]);
  if (v[0] == ss[0][0]) {
    if (ss[0][0] != 'X') vv.push_back(ss[0][0]);
    if (ss[0][1] != 'X') vv.push_back(ss[0][1]);
    if (ss[1][1] != 'X') vv.push_back(ss[1][1]);
    if (ss[1][0] != 'X') vv.push_back(ss[1][0]);
  } else if (ss[0][1] == v[0]) {
    if (ss[0][1] != 'X') vv.push_back(ss[0][1]);
    if (ss[1][1] != 'X') vv.push_back(ss[1][1]);
    if (ss[1][0] != 'X') vv.push_back(ss[1][0]);
    if (ss[0][0] != 'X') vv.push_back(ss[0][0]);
  } else if (v[0] == ss[1][1]) {
    vv.push_back(ss[1][1]);
    if (ss[1][0] != 'X') vv.push_back(ss[1][0]);
    if (ss[0][0] != 'X') vv.push_back(ss[0][0]);
    if (ss[0][1] != 'X') vv.push_back(ss[0][1]);
  } else if (v[0] == ss[1][0]) {
    if (ss[1][0] != 'X') vv.push_back(ss[1][0]);
    if (ss[0][0] != 'X') vv.push_back(ss[0][0]);
    if (ss[0][1] != 'X') vv.push_back(ss[0][1]);
    if (ss[1][1] != 'X') vv.push_back(ss[1][1]);
  }
  for (int i = 0; i < 3; i++)
    if (v[i] != vv[i]) {
      cout << "NO" << endl;
      return 0;
    }
  cout << "YES" << endl;
  return 0;
}
