#include <bits/stdc++.h>
using namespace std;
char s[2][3];
char s1[2][3];
char s2[2][3];
char s3[2][3];
int main() {
  scanf("%s", s[0]);
  scanf("%s", s[1]);
  scanf("%s", s1[0]);
  scanf("%s", s1[1]);
  string a;
  string b;
  if (s[0][0] == 'A') {
    a += 'A';
    if (s[0][1] != 'X') a += s[0][1];
    if (s[1][1] != 'X') a += s[1][1];
    if (s[1][0] != 'X') a += s[1][0];
  } else if (s[0][1] == 'A') {
    a += 'A';
    if (s[1][1] != 'X') a += s[1][1];
    if (s[1][0] != 'X') a += s[1][0];
    if (s[0][0] != 'X') a += s[0][0];
  } else if (s[1][0] == 'A') {
    a += 'A';
    if (s[0][0] != 'X') a += s[0][0];
    if (s[0][1] != 'X') a += s[0][1];
    if (s[1][1] != 'X') a += s[1][1];
  } else if (s[1][1] == 'A') {
    a += 'A';
    if (s[1][0] != 'X') a += s[1][0];
    if (s[0][0] != 'X') a += s[0][0];
    if (s[0][1] != 'X') a += s[0][1];
  }
  if (s1[0][0] == 'A') {
    b += 'A';
    if (s1[0][1] != 'X') b += s1[0][1];
    if (s1[1][1] != 'X') b += s1[1][1];
    if (s1[1][0] != 'X') b += s1[1][0];
  } else if (s1[0][1] == 'A') {
    b += 'A';
    if (s1[1][1] != 'X') b += s1[1][1];
    if (s1[1][0] != 'X') b += s1[1][0];
    if (s1[0][0] != 'X') b += s1[0][0];
  } else if (s1[1][0] == 'A') {
    b += 'A';
    if (s1[0][0] != 'X') b += s1[0][0];
    if (s1[0][1] != 'X') b += s1[0][1];
    if (s1[1][1] != 'X') b += s1[1][1];
  } else if (s1[1][1] == 'A') {
    b += 'A';
    if (s1[1][0] != 'X') b += s1[1][0];
    if (s1[0][0] != 'X') b += s1[0][0];
    if (s1[0][1] != 'X') b += s1[0][1];
  }
  if (a == "ABC" && b == "ABC")
    printf("YES\n");
  else if (a == "ACB" && b == "ACB")
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
