#include <iostream>
using namespace std;

#define DICE_MAX 100

class Dice{
    public:
    Dice(){
        top = south = east = west = north = bottom = 0;
    }
    
    Dice(int t, int s, int e, int w, int n, int b){
        top = t;
        south = s;
        east = e;
        west = w;
        north = n;
        bottom = b;
    };
    
    void setDice(int t, int s, int e, int w, int n, int b){
        top = t;
        south = s;
        east = e;
        west = w;
        north = n;
        bottom = b;
    };
    
    int getTop(){return top;}
    int getSouth(){return south;}
    int getEast(){return east;}
    int getWest(){return west;}
    int getNorth(){return north;}
    int getBottom(){return bottom;}

    void rollNorth();
    void rollWest();
    void rollEast();
    void rollSouth();

    void rotateLeft();
    void rotateRight();
    
    bool compare(const Dice d);
    bool rotateAndCompare(const Dice d);
    
    bool operator==(const Dice &d);
    
    private:
    int top, south, east, west, north, bottom;
};

bool Dice::compare(Dice d){
    if(top == d.getTop() && south == d.getSouth() && east == d.getEast() && west == d.getWest() && north == d.getNorth() && bottom == d.getBottom()) return true;
    else return false;
}

bool Dice::rotateAndCompare(const Dice d){
    Dice tmp1(top, south, east, west, north, bottom);
    int i;
    
    for(i = 0; i < 4; i++){
    tmp1.rotateRight();
    if(tmp1.compare(d)) return true;
    }
    
    return false;
}

bool Dice::operator==(const Dice &d){
    Dice tmp1(top, south, east, west, north, bottom);
    
    if(tmp1.rotateAndCompare(d)) return true;
    
    tmp1.rollNorth();
    if(tmp1.rotateAndCompare(d)) return true;
    
    tmp1.rollWest();
    if(tmp1.rotateAndCompare(d)) return true;
    
    tmp1.rollWest();
    if(tmp1.rotateAndCompare(d)) return true;
    
    tmp1.rollWest();
    if(tmp1.rotateAndCompare(d)) return true;
    
    tmp1.rollNorth();
    if(tmp1.rotateAndCompare(d)) return true;
    
    return false;
}

void Dice::rollNorth(){
    int tmp;
    tmp = top;
    top = south;
    south = bottom;
    bottom = north;
    north = tmp;
}

void Dice::rollSouth(){
    int tmp;
    tmp = top;
    top = north;
    north = bottom;
    bottom = south;
    south = tmp;
}

void Dice::rollEast(){
    int tmp;
    tmp = top;
    top = west;
    west = bottom;
    bottom = east;
    east = tmp;
}

void Dice::rollWest(){
    int tmp;
    tmp = top;
    top = east;
    east = bottom;
    bottom = west;
    west = tmp;
}

void Dice::rotateLeft(){
    int tmp;
    tmp = north;
    north = east;
    east = south;
    south = west;
    west = tmp;
}

void Dice::rotateRight(){
    int tmp;
    tmp = north;
    north = west;
    west = south;
    south = east;
    east = tmp;
}

int main(void){
    int t, s, e, w, n, b;
    int dice_n;
    Dice diceIV[DICE_MAX];
    int i, j;
    
    cin >> dice_n;
    for(i = 0; i < dice_n; i++){
        cin >> t >> s >> e >> w >> n >> b;
        diceIV[i].setDice(t, s, e, w, n, b);
    }
    
    for(i = 0; i < dice_n; i++){
        for(j = i + 1; j < dice_n; j++){
            if(diceIV[i] == diceIV[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3104