#include <bits/stdc++.h>
#include <cmath>

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
void print_line(vector<ll> &line) {
    for (int i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

struct Dice {

    int n, e, w, s, b, t;

    Dice north() {
        Dice d{t, e, w, b, n, s};
        return d;
    }

    Dice south() {
        Dice d{b, e, w, t, s, n};
        return d;
    }

    Dice west() {
        Dice d{n, b, t, s, w, e};
        return d;
    }

    Dice east() {
        Dice d{n, t, b, s, e, w};
        return d;
    }


    Dice roll(int to_e, int to_w, int to_s, int to_n) {
        Dice d = *this;
        rep(i, to_e) {
            d = d.east();
        }
        rep(i, to_w) {
            d = d.west();
        }
        rep(i, to_s) {
            d = d.south();
        }
        rep(i, to_n) {
            d = d.north();
        }
        return d;
    }

    Dice rotate(int i) {
        Dice d = *this;
        rep(j, i) {
            d = Dice{w, n, s, e, b, t};
        }
        return d;
    }

    void print() {
        cout << n << e << w << s << b << t << endl;
    }

    vector<Dice> all() {
        vector<Dice> ds;
        rep(j, 4) {
            rep(k, 4) {
                rep(l, 4) {
                    Dice rt = (*this).rotate(l);
                    Dice rl = rt.roll(j, 0, 0, k);
                    ds.push_back(rl);
                }
            }
        }
        return ds;
    }

    bool operator!=(const Dice &d) const {
        return !(*this == d);
    }

    bool operator==(const Dice &f) const {
        return n == f.n &&
               e == f.e &&
               w == f.w &&
               s == f.s &&
               b == f.b &&
               t == f.t;
    }

    Dice normalize() {
        vector<Dice> ds = (*this).all();
        return *min_element(ds.begin(), ds.end());
    }

    bool operator<(const Dice &f) const {
        if (n < f.n)return true;
        if (n > f.n)return false;
        if (e < f.e)return true;
        if (e > f.e)return false;
        if (w < f.w)return true;
        if (w > f.w)return false;
        if (s < f.s)return true;
        if (s > f.s)return false;
        if (b < f.b)return true;
        if (b > f.b)return false;
        if (t < f.t)return true;
        if (t > f.t)return false;
        return false;
    }
};

int main() {

    int n;
    cin >> n;
    vector<Dice> dices;
    rep(i, n) {
        Dice d;
        cin >> d.t >> d.s >> d.e >> d.w >> d.n >> d.b;
        dices.push_back(d.normalize());
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (dices[i] == dices[j]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;


}



Measured memory_bytes: 3168