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:
  
      # 入力
      def __init__(self, d1, d2, d3, d4, d5, d6):
          self.d1 = d1
          self.d2 = d2
          self.d3 = d3
          self.d4 = d4
          self.d5 = d5
          self.d6 = d6
  
      # 回転
      def roll(self, c):
          if c == "N":
              self.d1, self.d5, self.d6, self.d2 = self.d2, self.d1, self.d5, self.d6
          elif c == "S":
              self.d1, self.d5, self.d6, self.d2 = self.d5, self.d6, self.d2, self.d1
          elif c == "E":
              self.d1, self.d3, self.d6, self.d4 = self.d4, self.d1, self.d3, self.d6
          elif c == "W":
              self.d1, self.d3, self.d6, self.d4 = self.d3, self.d6, self.d4, self.d1
          elif c == "R":
              self.d2, self.d3, self.d5, self.d4 = self.d4, self.d2, self.d3, self.d5
          elif c == "L":
              self.d2, self.d3, self.d5, self.d4 = self.d3, self.d5, self.d4, self.d2
  
      # 上の面に来る最小値
      def minnum(self):
          return min(self.d1, self.d2, self.d3, self.d4, self.d5, self.d6)
  
      # 前の面に来る2つめに小さい値
      def min2num(self):
          return min(self.d2, self.d3, self.d4, self.d5, self.d6)
  
      # 2つめが下の面に来るときに前の面に来る3番目に小さい値
      def min3num(self):
          return min(self.d2, self.d3, self.d4, self.d5)
  
      # 回転動作
      def rolling(self):
          m = self.minnum()
          if m == self.d3:
              self.roll("W")
          elif m == self.d6:
              self.roll("E")
              self.roll("E")
          elif m == self.d4:
              self.roll("E")
          elif m == self.d2:
              self.roll("N")
          elif m == self.d5:
              self.roll("S")
          m = self.min2num()
          if m == self.d3:
              self.roll("L")
          elif m == self.d5:
              self.roll("L")
              self.roll("L")
          elif m == self.d4:
              self.roll("R")
          elif m == self.d6:
              m = self.min3num()
              if m == self.d3:
                  self.roll("L")
              elif m == self.d5:
                  self.roll("L")
                  self.roll("L")
              elif m == self.d4:
                  self.roll("R")
  
      # 値をリストで返す
      def returnlist(self):
          l = [self.d1, self.d2, self.d3, self.d4, self.d5, self.d6]
          return l
  
  
  n = int(input())
  check = True
  l = []
  
  # ダイスの入力
  for i in range(n):
      a, b, c, d, e, f = map(int, input().split())
      D = Dice(a, b, c, d, e, f)
      D.rolling()
  
      # 今までのダイスと比較
      for dice in l:
          if dice == D.returnlist():
              check = False
  
      # リストに追加
      l.append(D.returnlist())
  
  if check:
      print("Yes")
  else:
      print("No")
  
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"}]