#!/usr/bin/ruby
# -*- coding: utf-8 -*-
=begin
ITP1_11-C

Structure and Class - Dice III
Time Limit : 1 sec, Memory Limit : 65536 KB
???????????? III

Dice I ??¨????§????????????§?????\??????????????°?????????????????????????????????????????????????????????????????????????????????????????????????????°????????????????????????????????????Dice I ???????????§????????????????????¢???????????????????????????????????????????????????????????????????????°????????¨????????´????????¨?????????????????????????????¨??????????????????
Input

????????????????????????????????????????????¢?????°???????????????????????????????????????????????§?????????????????????
????????????????????????????????????????????¢?????°???????????????????????????????????????????????§?????????????????????
Output

??????????????????????????????????????° "Yes" ??¨?????°??????????????° "No" ??¨????????????????????????????????????
Constraints

    0???

??\?????????????????????????????¢?????°??? ???100

Sample Input 1

1 2 3 4 5 6
6 2 4 3 5 1

Sample Output 1

Yes


Sample Input 2

1 2 3 4 5 6
6 5 4 3 2 1

Sample Output 2

No

=end

class Dice
  def initialize(f)
    @face = Array.new(7,"")
    (0.upto(f.length-1)).each {|i| @face[i+1] = f[i]} 
  end

  def dump
    puts @face[1] + " " +  @face[2] + " " + @face[6] + " " +  @face[5] + " " + @face[4] + " " +  @face[3]
  end

  def e
    tmp = @face[1] 
    @face[1] = @face[4]
    @face[4] = @face[6]
    @face[6] = @face[3] 
    @face[3] = tmp
    @face[1]
  end

  def w
    tmp = @face[1] 
    @face[1] = @face[3]
    @face[3] = @face[6]
    @face[6] = @face[4]
    @face[4] = tmp
    @face[1]
  end

  def n
    tmp = @face[1] 
    @face[1] = @face[2]
    @face[2] = @face[6]
    @face[6] = @face[5]
    @face[5] = tmp
    @face[1]
  end

  def s
    tmp = @face[1] 
    @face[1] = @face[5]
    @face[5] = @face[6]
    @face[6] = @face[2]
    @face[2] = tmp
    @face[1]
  end

  def upface
    @face[1]
  end

  def frontface
    @face[2]
  end

  def rightface
    @face[3]
  end

  def face(i)
    @face[i]
  end

  def srchRight(s,t)
    (1..4).each {|i|
      break if self.frontface() == t;
      self.s
    }
    if self.frontface() != t then
      self.e
      (1..4).each {|i|
        break if self.frontface() == t;
        self.s
      }
    end
    abort "strange #{t} not found" if self.frontface() != t;
    (1..4).each {|i|
      break if self.upface() == s;
      self.e
    }
    abort "strange #{s} not found" if self.upface() != s;

    self.rightface()
  end

  def same?(d)
    (0..(@face.length-1)).each {|i| if self.face(i) != d.face(i) then
                                      return(false)
                                    end}
    true
  end
end

class Main
  def initialize
    #fh = open("IPT1_11_B.txt")
    fh = STDIN
    fl = fh.gets.chomp.split
    abort "small face data" + fl.join(" ") if fl.length != 6
    d1 = Dice.new(fl)

    fl = fh.gets.chomp.split
    abort "small face data" + fl.join(" ") if fl.length != 6
    d2 = Dice.new(fl)

    d2.srchRight(d1.upface(),d1.frontface())
    if d2.same?(d1) then
      puts "Yes"
    else
      puts "No"
    end
  end
end

if $0==__FILE__ then
  Main.new()
end

Measured memory_bytes: 8748