output_description: Print "Yes" if given dices are all different, otherwise "No" in a line.
input_description: In the first line, the number of dices $n$ is given. In the following $n$
  lines, six integers assigned to the dice faces are given respectively in the
  same way as Dice III.
attempt: # サイコロ        初期状態
  #    [1]           N
  # [4][2][3][5]   W[1]E
  #    [6]           S
  #
  # 上記の順番でラベルに対する整数が与えられる
  # l1 l2 l3 l4 l5 l6
  # 複数のサイコロが全て異なっていれば'Yes'
  # 1組でも一致していたら'No'
  import copy
  
  
  class Dice:
      def __init__(self, l1, l2, l3, l4, l5, l6):
          self.l1 = l1
          self.l2 = l2
          self.l3 = l3
          self.l4 = l4
          self.l5 = l5
          self.l6 = l6
          self.tmp = 0
  
      def move_n(self):
          self.tmp = self.l5
          self.l5 = self.l1
          self.l1 = self.l2
          self.l2 = self.l6
          self.l6 = self.tmp
  
      def move_s(self):
          self.tmp = self.l2
          self.l2 = self.l1
          self.l1 = self.l5
          self.l5 = self.l6
          self.l6 = self.tmp
  
      def move_e(self):
          self.tmp = self.l3
          self.l3 = self.l1
          self.l1 = self.l4
          self.l4 = self.l6
          self.l6 = self.tmp
  
      def move_w(self):
          self.tmp = self.l4
          self.l4 = self.l1
          self.l1 = self.l3
          self.l3 = self.l6
          self.l6 = self.tmp
  
      def show(self):
          return self.l1, self.l2, self.l3, self.l4, self.l5, self.l6
  
  
  n = int(input())
  yn_f = False
  d_inf1 = []
  d_inf2 = []
  for _ in range(n):
      d_inf1.append(Dice(*map(int, input().split())))
  d_inf2 = copy.deepcopy(d_inf1)
  
  for i, d1 in enumerate(d_inf1):
      for j, d2 in enumerate(d_inf2):
          if i == j:
              continue
          if set(d1.show()) == set(d2.show()):
              ne_switch = 0
              while d1.l2 != d2.l2:
                  if ne_switch <= 3:
                      d1.move_n()
                      ne_switch += 1
                  elif 4 == ne_switch:
                      d1.move_e()
                      ne_switch = 0
              e_cnt = 0
              while d1.l1 != d2.l1 and e_cnt <= 3:
                  d1.move_e()
                  e_cnt += 1
  
              if d1.l3 == d2.l3 and d1.l4 == d2.l4 and d1.l5 == d2.l5 and d1.l6 == d2.l6:
                  yn_f = True
          if yn_f:
              break
      if yn_f:
          break
  
  print("No" if yn_f else "Yes")
  
problem_description: Dice IV
  
    
  
  Write a program which reads $n$ dices constructed in the same way as Dice I,
  and determines whether they are all different. For the determination, use the
  same way as Dice III.
samples: [{"input": "3\n    1 2 3 4 5 6\n    6 2 4 3 5 1\n    6 5 4 3 2 1", "output": "No"}, {"input": "3\n    1 2 3 4 5 6\n    6 5 4 3 2 1\n    5 4 3 2 1 6", "output": "Yes"}]