#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
void solving() {
  char a[2][2];
  char b[2][2];
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < 2; j++) {
      cin >> b[i][j];
    }
  }
  string ori = "";
  if (a[0][0] != 'X') ori += a[0][0];
  if (a[0][1] != 'X') ori += a[0][1];
  if (a[1][1] != 'X') ori += a[1][1];
  if (a[1][0] != 'X') ori += a[1][0];
  string oria1 = "";
  if (a[0][0] != 'X') oria1 += a[0][0];
  if (a[1][0] != 'X') oria1 += a[1][0];
  if (a[1][1] != 'X') oria1 += a[1][1];
  if (a[0][1] != 'X') oria1 += a[0][1];
  string orib1 = "";
  if (b[0][0] != 'X') orib1 += b[0][0];
  if (b[0][1] != 'X') orib1 += b[0][1];
  if (b[1][1] != 'X') orib1 += b[1][1];
  if (b[1][0] != 'X') orib1 += b[1][0];
  string orib2 = "";
  if (b[0][0] != 'X') orib2 += b[0][0];
  if (b[1][0] != 'X') orib2 += b[1][0];
  if (b[1][1] != 'X') orib2 += b[1][1];
  if (b[0][1] != 'X') orib2 += b[0][1];
  orib1 += orib1;
  orib2 += orib2;
  if (strstr(orib1.c_str(), ori.c_str()))
    cout << "YES";
  else if (strstr(orib2.c_str(), oria1.c_str()))
    cout << "YES";
  else
    cout << "NO";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solving();
  return 0;
}
