D,d=$<.map &:split
y=[0,2,5,3]
f=->a,b{a.map{|i|d[i]}.rotate(b).map.with_index{|v,i|d[a[i]]=v}}
(1..24).map{|i|f[i%4>0?[0,4,5,1]:y,i/13>0?-1:1]
if d==D
puts:Yes
exit
end
(f[y,1]&&f[y,1])if i%12<1}
puts:No