class Matrix < Array
  attr_reader :n, :m
  def initialize(arr, row = false, cul = false)
    if (row and cul) or !(Array === arr[0])
      arr.flatten!
      super()
      for i in 0...row ||= arr.length
        self << [*arr[i * cul, cul]]
      end
      @n, @m = row, cul
    elsif Array === arr[0]
      super(arr)
      @n, @m = arr.length, arr[0].length
    else
      raise
    end
  end
  
  def self.e(row = 0)
    result = []
    for i in 0...row
      result << (0...row).map{|num|num == i ? 1: 0}
    end
    return Matrix.new(result)
  end
  
  def *(other)
    if Matrix === other
      return mmul(other)
    elsif Numeric === other
      return self.map{|item|item.map{|i|i * other}}
    end
  end
  
  def dup
    return Matrix.new(self.map(&:dup), @n, @m)
  end
  
  def **(num)
    if num == 0
      return 1
    else
      result = Matrix.e(@n)
      num.to_s(2).each_char{|c|result = result * result * self ** (c.to_i)}
      return result
    end
  end
  
  def to_s
    result = []
    for i in 0...@n
      result << self[i].join(" ")
    end
    return result
  end
  
  def to_ary
    self
  end
  
  private
  def mmul(other)
    result = []
    for i in 0... self.n
      for j in 0... other.m
        temp = 0
        for k in 0... self.m
          temp += self[i][k] * other[k][j]
        end
        result << temp
      end
    end
    return Matrix.new(result, self.n, other.m)
  end
end
class Dice
  attr_reader :att, :num
  def initialize(i, ii, iii, iv, v, vi, ichi = [0, 1, 0], ni = [0, 0, 1], san = [1, 0, 0], posx = 0, posy = 0)
    @att = Matrix.new([ichi, ni, san], 3, 3)
    @num = Array.new([nil, i, ii, iii, iv, v, vi])
    @x, @y = posx, posy
  end
  
  def ==(other)
    if (self.num && other.num) == other.num
      if (other.num.index(self.num[1]) + other.num.index(self.num[6]) == 7) and (other.num.index(self.num[2]) + other.num.index(self.num[5]) == 7)
        return ((@num[3] == other.set(@num[1], @num[2]).getx) and (@num[3] == other.set(@num[6], @num[5]).getx))
      else
        return false
      end
    else
      return false
    end
  end
  
  def dup
    return Dice.new(*@num[1..6].dup, *@att.dup, @x, @y)
  end
  
  def set(top, front)
    return self.dup.set!(top, front)
  end
  
  def set!(top, front)
    while top != gety or front != getz
     while top != gety and front != getz
       rotx!
     end
     while top == gety and front != getz
       roty!
     end
     while top != gety and front == getz
       rotz!
     end
    end
    return self
  end
  
  def getx(i = 1)
    return @num[i * (@att.index{|item|item[0] != 0} + 1) * @att.find{|item|item[0] != 0}[0]]
  end
  
  def gety(i = 1)
    return @num[i * (@att.index{|item|item[1] != 0} + 1) * @att.find{|item|item[1] != 0}[1]]
  end
  
  def getz(i = 1)
    return @num[i * (@att.index{|item|item[2] != 0} + 1) * @att.find{|item|item[2] != 0}[2]]
  end
  
  def rotx(i = 1)
    return self.dup.rotx!(i)
  end
  
  def roty(i = 1)
    return self.dup.roty!(i)
  end
  
  def rotz(i = 1)
    return self.dup.rotz!(i)
  end
  
  def rotx!(i = 1)
    @att *= Matrix.new([[1, 0, 0], [0, 0, -i], [0, i, 0]], 3, 3)
    return self
  end
  
  def roty!(i = 1)
    @att *= Matrix.new([[0, 0, i], [0, 1, 0], [-i, 0, 0]], 3, 3)
    return self
  end
  
  def rotz!(i = 1)
    @att *= Matrix.new([[0, -i, 0], [i, 0, 0], [0, 0, 1]], 3, 3)
    return self
  end
end
if Dice.new(*gets.split(" ").map(&:to_i)) == Dice.new(*gets.split(" ").map(&:to_i))
  puts "Yes"
else
  puts "No"
end