#include <iostream>
#include <stdio.h>
#include <math.h>

#define DICE_SIZE 6
#define MAX_DICE_NUM 100

class Dice
{
private:
	int eyes[DICE_SIZE];
public:
	Dice() {}

	Dice(int e1, int e2, int e3, int e4, int e5, int e6)
	{
		eyes[0] = e1;
		eyes[1] = e2;
		eyes[2] = e3;
		eyes[3] = e4;
		eyes[4] = e5;
		eyes[5] = e6;
	}

	int GetEye(int i)
	{
		return eyes[i];
	}

	void Roll(char c)
	{
		switch (c)
		{
		case 'E':
		case 'e':
			ToEest();
			break;

		case 'N':
		case 'n':
			ToNorth();
			break;

		case 'S':
		case 's':
			ToSouth();
			break;

		case 'W':
		case 'w':
			ToWest();
			break;

		default:
			break;
		}
	}

	void ToEest()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[3];
		eyes[1] = temp[1];
		eyes[2] = temp[0];
		eyes[3] = temp[5];
		eyes[4] = temp[4];
		eyes[5] = temp[2];
	}

	void ToNorth()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[1];
		eyes[1] = temp[5];
		eyes[2] = temp[2];
		eyes[3] = temp[3];
		eyes[4] = temp[0];
		eyes[5] = temp[4];
	}

	void ToSouth()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[4];
		eyes[1] = temp[0];
		eyes[2] = temp[2];
		eyes[3] = temp[3];
		eyes[4] = temp[5];
		eyes[5] = temp[1];
	}

	void ToWest()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[2];
		eyes[1] = temp[1];
		eyes[2] = temp[5];
		eyes[3] = temp[0];
		eyes[4] = temp[4];
		eyes[5] = temp[3];
	}

	void TurnClockWise()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[0];
		eyes[1] = temp[2];
		eyes[2] = temp[4];
		eyes[3] = temp[1];
		eyes[4] = temp[3];
		eyes[5] = temp[5];
	}
};

Dice dices[MAX_DICE_NUM];

bool isSame(Dice dice1, Dice dice2)
{
	// 上下二面を合わせる
	for (int i = 0; i < 4; i++)
	{
		if (dice1.GetEye(0) == dice2.GetEye(0) &&
			dice1.GetEye(5) == dice2.GetEye(5)) break;
		dice1.Roll('N');
	}
	if (dice1.GetEye(0) != dice2.GetEye(0) ||
		dice1.GetEye(5) != dice2.GetEye(5))
	{
		for (int i = 0; i < 4; i++)
		{
			if (dice1.GetEye(0) == dice2.GetEye(0) &&
				dice1.GetEye(5) == dice2.GetEye(5)) break;
			dice1.Roll('E');
		}
	}
	if (dice1.GetEye(0) != dice2.GetEye(0) ||
		dice1.GetEye(5) != dice2.GetEye(5))
	{
		return false;
	}

	// その他4面を合わせる
	for (int i = 0; i < 4; i++)
	{
		if (dice1.GetEye(1) == dice2.GetEye(1) &&
			dice1.GetEye(2) == dice2.GetEye(2) &&
			dice1.GetEye(3) == dice2.GetEye(3) &&
			dice1.GetEye(4) == dice2.GetEye(4)) break;
		dice1.TurnClockWise();
	}
	if (dice1.GetEye(1) != dice2.GetEye(1) ||
		dice1.GetEye(2) != dice2.GetEye(2) ||
		dice1.GetEye(3) != dice2.GetEye(3) ||
		dice1.GetEye(4) != dice2.GetEye(4))
	{
		return false;
	}
	return true;
}

int main()
{
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		int e1, e2, e3, e4, e5, e6;
		scanf("%d %d %d %d %d %d", &e1, &e2, &e3, &e4, &e5, &e6);
		Dice dice(e1, e2, e3, e4, e5, e6);
		dices[i] = dice;
	}

	bool flag = true;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (isSame(dices[i], dices[j])) flag = false;
		}
	}
	if (flag)
	{
		std::cout << "Yes" << std::endl;
	}
	else
	{
		std::cout << "No" << std::endl;
	}
}


Measured memory_bytes: 3220