using System;
using System.Collections;


namespace ConsoleApplication12
{
    class Dice
    {
        int[] dArray;

        public Dice(string[] a)
        {
            dArray = Parse(a);
        }

        public void RollToTop(int diceIndex)
        {
            switch (diceIndex)
            {
                case 0:
                    break;

                case 1:
                    RollNorth();
                    break;

                case 2:
                    RollWest();
                    break;

                case 3:
                    RollEast();
                    break;

                case 4:
                    RollSouth();
                    break;

                case 5:
                    RollNorth();
                    RollNorth();
                    break;
            }

        }

        void RollNorth()
        {
            int temp;
            temp = dArray[0];
            dArray[0] = dArray[1];
            dArray[1] = dArray[5];
            dArray[5] = dArray[4];
            dArray[4] = temp;
        }

        void RollEast()
        {
            int temp;
            temp = dArray[0];
            dArray[0] = dArray[3];
            dArray[3] = dArray[5];
            dArray[5] = dArray[2];
            dArray[2] = temp;
        }

        void RollSouth()
        {
            int temp;
            temp = dArray[0];
            dArray[0] = dArray[4];
            dArray[4] = dArray[5];
            dArray[5] = dArray[1];
            dArray[1] = temp;
        }

        void RollWest()
        {
            int temp;
            temp = dArray[0];
            dArray[0] = dArray[2];
            dArray[2] = dArray[5];
            dArray[5] = dArray[3];
            dArray[3] = temp;
        }

        public void RollSide()
        {
            int temp;
            temp = dArray[2];
            dArray[2] = dArray[1];
            dArray[1] = dArray[3];
            dArray[3] = dArray[4];
            dArray[4] = temp;
        }

        //??????¢?????????´??????????????????
        public bool IsEqualToAllFaces(int[] d)
        {
            for (int i = 0; i < dArray.Length; ++i)
            {
                if (dArray[i] != d[i])
                {
                    return false;
                }
            }
            return true;
        }
        /// <summary>
        /// ??????????????????????????????????????????
        /// </summary>
        /// <param name="d2">??????????????????????????????</param>
        /// <returns>??????????????????</returns>
        public bool IsSameAsDice(Dice d2)
        {
            for (int i = 0; i < d2.dArray.Length; ++i)
            {
                if (d2.dArray[0] == dArray[i])
                {
                    RollToTop(i);

                    for (int j = 0; j < 4; ++j)
                    {
                        if (IsEqualToAllFaces(d2.dArray))
                        {
                            return true;
                        }
                        RollSide();
                    }

                }
            }
            return false;
        }


        public int[] Parse(string[] str)
        {
            int[] intArray = new int[str.Length];
            for (int i = 0; i < str.Length; ++i)
            {
                intArray[i] = int.Parse(str[i]);
            }
            return intArray;
        }

    }



    class Program
    {
        static void Main()
        {

            int n = int.Parse(Console.ReadLine());
            bool b = false;
            Dice[] dice = new Dice[n];
            string[] str = new string[n];

            for (int i = 0; i < n; ++i)
            {
                str[i] = Console.ReadLine();
                dice[i] = new Dice(str[i].Split(' '));
            }



            for (int i = 0; i < n; ++i)
            {
                if (b)
                {
                    break;
                }

                for (int j = (i + 1); j < n; ++j)
                {

                    b = dice[i].IsSameAsDice(dice[j]);
                    if (b)
                    {
                        break;
                    }
                }
            }

            if (b)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }

        }
    }
}

Measured memory_bytes: 9020