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: n = int(input())
  d = {i: list(input().split()) for i in range(n)}
  
  
  def roll(Dice, Vector):
      if Vector == "N":
          c = Dice[0]
          Dice[0] = Dice[1]
          Dice[1] = Dice[5]
          Dice[5] = Dice[4]
          Dice[4] = c
      elif Vector == "W":
          c = Dice[0]
          Dice[0] = Dice[2]
          Dice[2] = Dice[5]
          Dice[5] = Dice[3]
          Dice[3] = c
      elif Vector == "E":
          c = Dice[0]
          Dice[0] = Dice[3]
          Dice[3] = Dice[5]
          Dice[5] = Dice[2]
          Dice[2] = c
      elif Vector == "S":
          c = Dice[0]
          Dice[0] = Dice[4]
          Dice[4] = Dice[5]
          Dice[5] = Dice[1]
          Dice[1] = c
  
  
  v = list("NNNNWNNNWNNNENNNENNNWNNN")
  f = 0
  for i in range(n):
      if f == 0:
          for item in v:
              roll(d[i], item)
              if f == 0:
                  for j in range(i + 1, n):
                      if d[i] == d[j]:
                          f += 1
                          break
  if f == 0:
      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"}]