#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>
#include <cstdio>
#include <bitset>
#include <map>
#include <string>
#include <valarray>
// #include <cctype>

#define INF -1

using namespace std;
/*  class   */
class Dice
{
    public:
        void assign();
        void roll(char);
        void roll_W();
        void roll_E();
        void roll_S();
        void roll_N();
        void rotate();
        int top() const;
        int front() const;
        int right() const;
        bool operator==(const Dice & a) const;


    private:
        vector<int> face;
        // int face[7];
        // string west = "face4", east = "face3",
        //         south = "face2" , north = "face5",
        //         bottom = "face6", top = "face1";
        int W = 4, E = 3, S = 2, N = 5, B = 6, T = 1;
};


bool is_the_same(Dice dice1, Dice dice2);


int main()
{
    vector<Dice> dices;

    int n;
    cin >> n;

    dices.resize(n);

    int i = -1;
    while (++i< n)
        dices[i].assign();

    bool result = true;
    for (int i = 0; i < n-1; i++)
        for (int j = i+1; j < n; j++)
        {
            if (is_the_same(dices[i], dices[j]))
                result = false;
        }

    if (result)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}




void Dice::assign()
{
    face.resize(7);
    int i = 0;
    while (i++ < 6)
    {
        cin >> face[i];
    }
    cin.ignore();

}

void Dice::roll(char ch)
{
    if (ch == 'W')
        roll_W();
    else if (ch == 'E')
        roll_E();
    else if (ch == 'S')
        roll_S();
    else
        roll_N();
}


void Dice::roll_W()
{
    int temp = W;
    W = T;
    T = E;
    E = B;
    B = temp;
}

void Dice::roll_E()
{
    int temp = E;
    E = T;
    T = W;
    W = B;
    B = temp;
}

void Dice::roll_S()
{
    int temp = S;
    S = T;
    T = N;
    N = B;
    B = temp;
}

void Dice::roll_N()
{
    int temp = N;
    N = T;
    T = S;
    S = B;
    B = temp;
}

void Dice::rotate()
{
    int temp = S;
    S = W;
    W = N;
    N = E;
    E = temp;            
}

int Dice::top() const
{
    return face[T];
}

int Dice::front() const
{
    return face[S];
}

int Dice::right() const
{
    return face[E];
}


bool Dice::operator==(const Dice & a) const
{

    return (face[W]==a.face[a.W] && 
            face[E]==a.face[a.E] && 
            face[S]==a.face[a.S] && 
            face[N]==a.face[a.N] && 
            face[T]==a.face[a.T] && 
            face[B]==a.face[a.B]);
        
}


bool is_the_same(Dice dice1, Dice dice2)
{
    bool result = false;

    for (int i = 0; i < 4; i++)
    {
        if (dice1 == dice2)
        {
            result = true;
            break;
        }

        dice1.roll_W();

        for (int j = 0; j < 4; j++)
        {
            if (dice1 == dice2)
            {
                result = true;
                break;
            }
            
            dice1.roll_N();

            for (int k = 0; k < 4; k++)
            {
                if (dice1 == dice2)
                {
                    result = true;
                    break;
                }
                
                dice1.rotate();                    
            }
        }
    }


    return result;    
}


Measured memory_bytes: 3168