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: import random
  
  
  class dice:
      def __init__(self, t, S, E):
          self.dice = list(map(int, input().split()))
          self.t = t
          self.S = S
          self.E = E
          self.now_dice()
  
      def roll(self, order):
          if order == "E":
              self.t, self.E = self.W, self.t
          elif order == "N":
              self.t, self.S = self.S, self.g
          elif order == "S":
              self.t, self.S = self.N, self.t
          elif order == "W":
              self.t, self.E = self.E, self.g
          self.now_dice()
  
      def now_dice(self):
          self.N = 7 - self.S
          self.g = 7 - self.t
          self.W = 7 - self.E
          self.now = [self.t, self.S, self.E, self.N, self.W, self.g]
          return self.now
  
  
  if __name__ == "__main__":
      num = int(input())
      dice_1 = dice(1, 2, 3)
      direc = ["N", "E", "W", "S"]
      x = 0
      for _ in range(num - 1):
          dice_2 = dice(1, 2, 3)
          for __ in range(1200):
              random.shuffle(direc)
              dice_2.roll(direc[0])
              if [dice_1.dice[dice_1.now[v] - 1] for v in range(6)] == [
                  dice_2.dice[dice_2.now[v] - 1] for v in range(6)
              ]:
                  x += 1
                  break
      if x >= 1:
          print("No")
      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"}]