Problem:
MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});

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.

Input

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.

Output

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

Constraints

$2 \leq n \leq 100$

$0 \leq $ the integer assigned to a face $ \leq 100$

Sample Input 1

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

Sample Output 1

No

Sample Input 2

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

Sample Output 2

Yes

Solution in C# (judge verdict: Wrong Answer)

using System;
using System.Collections.Generic;

public class Program
{
    /// <summary>
    /// プログラムエントリポイント
    /// </summary>
    public static void Main()
    {
        //サイコロの個数入力
        int countDice = int.Parse(Console.ReadLine());

        //複数個のサイコロを格納するlist生成
        List<int[]> listDice = new List<int[]>();

        //サイコロの個数文繰り返す
        for (int i = 0; i < countDice; i++)
        {
            //繰り返す都度 配列生成
            int[] aryIntDice = new int[6];

            //サイコロの目入力
            string[] aryStrDice = Console.ReadLine().Split(' ');

            //srting[] を int[] に置き換える
            for (int j = 0; j < 6; j++)
            {
                aryIntDice[i] = int.Parse(aryStrDice[i]);
            }
            
            //置き換えたint[]をlistに格納
            listDice.Add(aryIntDice);
        }

        //サイコロどおしが一緒の数
        int count = 0;
        //比較用配列１
        int[] aryIntDice1 = new int[6];
        //比較用配列２
        int[] aryIntDice2 = new int[6];

        for (int i = 0; i < countDice; i++)
        {
            for (int j = 0; j < countDice; j++)
            {
                
                aryIntDice1 = listDice[i];
                aryIntDice2 = listDice[j];

                

                //同じサイコロを比較しないように
                if (i != j)
                {

                    Dice insDice = new Dice(aryIntDice1, aryIntDice2);

                    if (insDice.judgeDice())
                    {
                        count++;
                    }
                }
            }
        }

        if (count == 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }

    }

}

/// <summary>
/// Diceクラス
/// </summary>
class Dice
{
    int[] aryIntDice1;
    int[] aryIntDice2;

    public Dice(int[] aryIntDice1, int[] aryIntDice2)
    {
        this.aryIntDice1 = aryIntDice1;
        this.aryIntDice2 = aryIntDice2;
    }

    public bool judgeDice()
    {
        //E方向,N方向に4回ずつ動かしたいので 2回繰り返す
        for (int x = 0; x < 2; x++)
        {
            // E,N方向に4回動かす
            for (int i = 0; i < 4; i++)
            {
                //サイコロどうしが同じか判断
                if (checkAllDice())
                {
                    return true;
                }

                // x が0の間 E 方向に動かす
                if (x == 0)
                {
                    runOperationE();
                }
                // x が0以外の間 N 方向に動かす
                else
                {
                    runOperationN();
                }

                // サイコロを4回右回転させる
                for (int j = 0; j < 4; j++)
                {
                    //サイコロどうしが同じか判断
                    if (checkAllDice())
                    {
                        return true;
                    }

                    //右回転させる
                    runOperationR();

                }

            }
        }
        return false;
    }

    /// <summary>
    /// サイコロ１とサイコロ２のすべての目が同じか判断
    /// </summary>
    /// <returns>bool</returns>
    private bool checkAllDice()
    {
        if (aryIntDice1[0] == aryIntDice2[0] && aryIntDice1[1] == aryIntDice2[1] &&
             aryIntDice1[2] == aryIntDice2[2] && aryIntDice1[3] == aryIntDice2[3] &&
                aryIntDice1[4] == aryIntDice2[4] && aryIntDice1[5] == aryIntDice2[5])
        {
            return true;
        }
        return false;
    }

    /// <summary>
    /// サイコロを命令に従って動かす E方向
    /// </summary>
    private void runOperationE()
    {
        int tmpStorage = aryIntDice1[0];
        aryIntDice1[0] = aryIntDice1[3];
        aryIntDice1[3] = aryIntDice1[5];
        aryIntDice1[5] = aryIntDice1[2];
        aryIntDice1[2] = tmpStorage;
    }
    /// <summary>
    /// サイコロを命令に従って動かす N方向
    /// </summary>
    private void runOperationN()
    {
        int tmpStorage = aryIntDice1[0];
        aryIntDice1[0] = aryIntDice1[1];
        aryIntDice1[1] = aryIntDice1[5];
        aryIntDice1[5] = aryIntDice1[4];
        aryIntDice1[4] = tmpStorage;
    }
    /// <summary>
    /// サイコロを命令に従って動かす S方向
    /// </summary>
    private void runOperationS()
    {
        int tmpStorage = aryIntDice1[0];
        aryIntDice1[0] = aryIntDice1[4];
        aryIntDice1[4] = aryIntDice1[5];
        aryIntDice1[5] = aryIntDice1[1];
        aryIntDice1[1] = tmpStorage;
    }
    /// <summary>
    /// サイコロを命令に従って動かす W方向
    /// </summary>
    private void runOperationW()
    {
        int tmpStorage = aryIntDice1[0];
        aryIntDice1[0] = aryIntDice1[2];
        aryIntDice1[2] = aryIntDice1[5];
        aryIntDice1[5] = aryIntDice1[3];
        aryIntDice1[3] = tmpStorage;
    }

    /// <summary>
    /// サイコロを命令に従って動かす 右ロール
    /// </summary>
    private void runOperationR()
    {
        int tmpStorage = aryIntDice1[1];
        aryIntDice1[1] = aryIntDice1[2];
        aryIntDice1[2] = aryIntDice1[4];
        aryIntDice1[4] = aryIntDice1[3];
        aryIntDice1[3] = tmpStorage;
    }


}