### BUGGY CODE ###

import random

class Dice:
  def __init__(self, list = map(str, range(1, 7))):
    self.top = list[0]
    self.front = list[1]
    self.right = list[2]
    self.left = list[3]
    self.back = list[4]
    self.bottom = list[5]

    self.dic = {}
    for i in xrange(6):
      if list[i] in self.dic:
        self.dic[list[i]] += 1
      else:
        self.dic[list[i]] = 1

  def print_all(self):
    print "top = " + self.top + ", front = " + self.front + ", right = " + self.right + ", left = " + self.left + ", back = " + self.back + ", bottom = " + self.bottom

  def roll_N(self):
    temp = self.top
    self.top = self.front
    self.front = self.bottom
    self.bottom = self.back
    self.back = temp

  def roll_S(self):
    temp = self.top
    self.top = self.back
    self.back = self.bottom
    self.bottom = self.front
    self.front = temp

  def roll_W(self):
    temp = self.top
    self.top = self.right
    self.right = self.bottom
    self.bottom = self.left
    self.left = temp

  def roll_E(self):
    temp = self.top
    self.top = self.left
    self.left = self.bottom
    self.bottom = self.right
    self.right = temp

  def roll_C(self):
    temp = self.front
    self.front = self.right
    self.right = self.back
    self.back = self.left
    self.left = temp

  def random_roll(self):
    ram = random.randint(1, 4)
    if ram == 1:
      self.roll_E()
    elif ram == 2:
      self.roll_N()
    elif ram == 3:
      self.roll_S()
    else:
      self.roll_W()

  def getDifference(self, dice):
    same_list = []
    different_list = []
    if self.top == dice.top:
      same_list.append("top")
    else:
      different_list.append("top")
    if self.front == dice.front:
      same_list.append("front")
    else:
      different_list.append("front")
    if self.left == dice.left:
      same_list.append("left")
    else:
      different_list.append("left")
    if self.back == dice.back:
      same_list.append("back")
    else:
      different_list.append("back")
    if self.right == dice.right:
      same_list.append("right")
    else:
      different_list.append("right")
    if self.bottom == dice.bottom:
      same_list.append("bottom")
    else:
      different_list.append("bottom")

    result_list = [same_list, different_list]
    return result_list

  def getList(self):
    list = [self.top, self.front, self.right, self.left, self.back, self.bottom]
    return list

first_dice = Dice(raw_input().split(" "))
second_dice = Dice(raw_input().split(" "))

def print_dices():
  print "first dice: "
  first_dice.print_all()
  print "second dice: "
  second_dice.print_all() 

num = 0
while num < 4:
  dic1_keys = first_dice.dic.keys()
  for i in xrange(len(dic1_keys)):
    if first_dice.dic[dic1_keys[i]] != second_dice.dic[dic1_keys[i]]:
      num = 4
      break

  # print_dices()

  diferece = first_dice.getDifference(second_dice)
  # print diferece

  if len(diferece[0]) == 6:
    break

  if "front" in diferece[0] and "back" in diferece[0]:
    first_dice.roll_W()
    num += 1
  elif "left" in diferece[0] and "right" in diferece[0]:
    first_dice.roll_S()
    num += 1
  elif "top" in diferece[0] and "bottom" in diferece[0]:
    first_dice.roll_C()
    num += 1
  else:
    first_dice.random_roll()

if num == 4:
  print "No"
else:
  print "Yes"

### FIXED CODE ###

import random

class Dice:
  def __init__(self, list = map(str, range(1, 7))):
    self.top = list[0]
    self.front = list[1]
    self.right = list[2]
    self.left = list[3]
    self.back = list[4]
    self.bottom = list[5]

    self.dic = {}
    for i in xrange(6):
      if list[i] in self.dic:
        self.dic[list[i]] += 1
      else:
        self.dic[list[i]] = 1

  def print_all(self):
    print "top = " + self.top + ", front = " + self.front + ", right = " + self.right + ", left = " + self.left + ", back = " + self.back + ", bottom = " + self.bottom

  def roll_N(self):
    temp = self.top
    self.top = self.front
    self.front = self.bottom
    self.bottom = self.back
    self.back = temp

  def roll_S(self):
    temp = self.top
    self.top = self.back
    self.back = self.bottom
    self.bottom = self.front
    self.front = temp

  def roll_W(self):
    temp = self.top
    self.top = self.right
    self.right = self.bottom
    self.bottom = self.left
    self.left = temp

  def roll_E(self):
    temp = self.top
    self.top = self.left
    self.left = self.bottom
    self.bottom = self.right
    self.right = temp

  def roll_C(self):
    temp = self.front
    self.front = self.right
    self.right = self.back
    self.back = self.left
    self.left = temp

  def random_roll(self):
    ram = random.randint(1, 4)
    if ram == 1:
      self.roll_E()
    elif ram == 2:
      self.roll_N()
    elif ram == 3:
      self.roll_S()
    else:
      self.roll_W()

  def getDifference(self, dice):
    same_list = []
    different_list = []
    if self.top == dice.top:
      same_list.append("top")
    else:
      different_list.append("top")
    if self.front == dice.front:
      same_list.append("front")
    else:
      different_list.append("front")
    if self.left == dice.left:
      same_list.append("left")
    else:
      different_list.append("left")
    if self.back == dice.back:
      same_list.append("back")
    else:
      different_list.append("back")
    if self.right == dice.right:
      same_list.append("right")
    else:
      different_list.append("right")
    if self.bottom == dice.bottom:
      same_list.append("bottom")
    else:
      different_list.append("bottom")

    result_list = [same_list, different_list]
    return result_list

  def getList(self):
    list = [self.top, self.front, self.right, self.left, self.back, self.bottom]
    return list

first_dice = Dice(raw_input().split(" "))
second_dice = Dice(raw_input().split(" "))

def print_dices():
  print "first dice: "
  first_dice.print_all()
  print "second dice: "
  second_dice.print_all()
  print first_dice.dic

line = "#######################################"

flag = False
num = 0
debug = 0
while num < 4:
  # debug += 1
  # if debug > 10:
  #   break
  # print line

  dic1_keys = first_dice.dic.keys()
  for i in xrange(len(dic1_keys)):
    if first_dice.dic[dic1_keys[i]] != second_dice.dic[dic1_keys[i]]:
      num = 4
      break

  for i in xrange(len(dic1_keys)):
    if first_dice.dic[dic1_keys[i]] == 6 or first_dice.dic[dic1_keys[i]] == 5:
      num = 4
      flag = True
      break

  # print_dices()

  diferece = first_dice.getDifference(second_dice)
  # print diferece

  same_num = len(diferece[0])
  if same_num == 6:
    break
  elif same_num == 5:
    num = 4
    break

  if "front" in diferece[0] or "back" in diferece[0]:
    first_dice.roll_W()
    num += 1
  elif "left" in diferece[0] or "right" in diferece[0]:
    first_dice.roll_S()
    num += 1
  elif "top" in diferece[0] or "bottom" in diferece[0]:
    first_dice.roll_C()
    num += 1
  else:
    first_dice.random_roll()

if flag == True:
  print "Yes"
elif num == 4:
  print "No"
else:
  print "Yes"