#D11929. Dice IV

    ID: 9923 Type: Default 1000ms 134MiB

Dice IV

Dice IV

Write a program which reads nn 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.

Constraints

  • 2n1002 \leq n \leq 100
  • 00 \leq the integer assigned to a face 100 \leq 100

Input

In the first line, the number of dices nn is given. In the following nn lines, six integers assigned to the dice faces are given respectively in the same way as Dice III.

Output

Print "Yes" if given dices are all different, otherwise "No" in a line.

Examples

Input

3 1 2 3 4 5 6 6 2 4 3 5 1 6 5 4 3 2 1

Output

No

Input

3 1 2 3 4 5 6 6 5 4 3 2 1 5 4 3 2 1 6

Output

Yes

inputFormat

Input

In the first line, the number of dices nn is given. In the following nn lines, six integers assigned to the dice faces are given respectively in the same way as Dice III.

outputFormat

Output

Print "Yes" if given dices are all different, otherwise "No" in a line.

Examples

Input

3 1 2 3 4 5 6 6 2 4 3 5 1 6 5 4 3 2 1

Output

No

Input

3 1 2 3 4 5 6 6 5 4 3 2 1 5 4 3 2 1 6

Output

Yes

样例

3
1 2 3 4 5 6
6 5 4 3 2 1
5 4 3 2 1 6
Yes