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: class Dice:
      same_dice_index = (
          (0, 1, 2, 3, 4, 5),
          (0, 2, 4, 1, 3, 5),
          (0, 3, 1, 4, 2, 5),
          (0, 4, 3, 2, 1, 5),
          (1, 0, 3, 2, 5, 4),
          (1, 2, 0, 5, 3, 4),
          (1, 3, 5, 0, 2, 4),
          (1, 5, 2, 3, 0, 4),
          (2, 0, 1, 4, 5, 3),
          (2, 1, 5, 0, 4, 3),
          (2, 4, 0, 5, 1, 3),
          (2, 5, 4, 1, 0, 3),
          (3, 0, 4, 1, 5, 2),
          (3, 1, 0, 5, 4, 2),
          (3, 4, 5, 0, 1, 2),
          (3, 5, 1, 4, 0, 2),
          (4, 0, 2, 3, 5, 1),
          (4, 2, 5, 0, 3, 1),
          (4, 3, 0, 5, 2, 1),
          (4, 5, 3, 2, 0, 1),
          (5, 1, 3, 2, 4, 0),
          (5, 2, 1, 4, 3, 0),
          (5, 3, 4, 1, 2, 0),
          (5, 4, 2, 3, 1, 0),
      )
  
      def __init__(self, str_list):
          self.faces = str_list
  
      def is_same(self, dice):
          for i in Dice.same_dice_index:
              for n, j in enumerate(i):
                  if dice.faces[n] != self.faces[j]:
                      break
              else:
                  return True
          return False
  
      def is_unique(self, dices_list):
          for i in dices_list:
              if self.is_same(i):
                  return False
          return True
  
  
  import sys
  
  n = int(sys.stdin.readline())
  
  dices = []
  
  for i in range(n):
      str_list = sys.stdin.readline().split()
      new_dice = Dice(str_list)
      if not new_dice.is_unique(dices):
          print("No")
          break
      dices.append(new_dice)
  else:
      print("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"}]