using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Dice_II
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());

            List<Dice> dices = new List<Dice>();

            for (int i = 0; i < num; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                Dice dice = new Dice(input);
                dices.Add(dice);
            }

            string ctr = " zzzxyyyzxxxzyyyzxxxyzzz";
            foreach (Dice item in dices)
            { 
                for (int i = 0; i < ctr.Length; i++)
                {
                    item.Rotate(ctr[i]);
                    for(int k = dices.IndexOf(item)+1; k<num;k++)
                    {
                        for (int j = 0; j < ctr.Length; j++)
                        {
                            dices[k].Rotate(ctr[j]);
                            if (item.top.Equals(dices[k].top) && item.front.Equals(dices[k].front))
                            {
                                if (item.right.Equals(dices[k].right))
                                {
                                    if (item.back.Equals(dices[k].back))
                                    {
                                        if (item.left.Equals(dices[k].left))
                                        {
                                            if (item.bottom.Equals(dices[k].bottom))
                                            {
                                                Console.WriteLine("No");
                                                return;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            Console.WriteLine("Yes");
            
        }
    }

    class Dice
    {
        public string top, front, right, left, back, bottom;

        public Dice(string[] input)
        {
            this.top = input[0];
            this.front = input[1];
            this.right = input[2];
            this.left = input[3];
            this.back = input[4];
            this.bottom = input[5];
        }

        void RotateX()
        {
            string temp = this.top;
            this.top = this.front;
            this.front = this.bottom;
            this.bottom = this.back;
            this.back = temp;
        }

        void RotateY()
        {
            string temp = this.front;
            this.front = this.right;
            this.right = this.back;
            this.back = this.left;
            this.left = temp;
        }

        void RotateZ()
        {
            string temp = this.top;
            this.top = this.left;
            this.left = this.bottom;
            this.bottom = this.right;
            this.right = temp;
        }

        public void Rotate(char ctr)
        {
            switch (ctr)
            {
                case 'x':
                    RotateX();
                    break;
                case 'y':
                    RotateY();
                    break;
                case 'z':
                    RotateZ();
                    break;
                default:
                    break;
            }
        }

    }
}



Measured memory_bytes: 17960