def roll(die, d):

    if d == "E":

        return [die[3], die[1], die[0], die[5], die[4], die[2]]

    if d == "N":

        return [die[1], die[5], die[2], die[3], die[0], die[4]]

    if d == "S":

        return [die[4], die[0], die[2], die[3], die[5], die[1]]

    if d == "W":

        return [die[2], die[1], die[5], die[0], die[4], die[3]]

    if d == "L":

        return [die[0], die[3], die[1], die[4], die[2], die[5]]

    if d == "R":

        return [die[0], die[2], die[4], die[1], die[3], die[5]]



def checkdice(die1, die2):

    ans = False

    for d in "RRRNRRRNRRRSRRRSRRRNRRRR":

        if die1 == die2:

            ans = True

            break

        die2 = roll(die2, d)

    return ans



dice = []

msg = "Yes"

n = int(eval(input()))

for _ in range(n):

    dice.append(list(map(int, input().split())))

for i in range(n):

    for j in range(i + 1, n):

        if checkdice(dice[i], dice[j]):

            msg = "No"

print(msg)
def roll(die, d):

    if d == "E":

        return [die[3], die[1], die[0], die[5], die[4], die[2]]

    if d == "N":

        return [die[1], die[5], die[2], die[3], die[0], die[4]]

    if d == "S":

        return [die[4], die[0], die[2], die[3], die[5], die[1]]

    if d == "W":

        return [die[2], die[1], die[5], die[0], die[4], die[3]]

    if d == "L":

        return [die[0], die[3], die[1], die[4], die[2], die[5]]

    if d == "R":

        return [die[0], die[2], die[4], die[1], die[3], die[5]]



def checkdice(die1, die2):

    ans = False

    for d in "RRRNRRRNRRRSRRRSRRRNRRRR":

        if die1 == die2:

            ans = True

            break

        die2 = roll(die2, d)

    return ans



dice = []

msg = "Yes"

n = int(eval(input()))

for _ in range(n):

    dice.append(list(map(int, input().split())))

for i in range(n):

    for j in range(i + 1, n):

        if checkdice(dice[i], dice[j]):

            msg = "No"

            break

    if msg == "No":

        break

print(msg)
def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]


def checkdice(die1, die2):
    ans = False
    for d in "RRRNRRRNRRRSRRRSRRRNRRRR":
        if die1 == die2:
            ans = True
            break
        die2 = roll(die2, d)
    return ans


dice = []
msg = "Yes"
n = int(eval(input()))
for _ in range(n):
    dice.append(list(map(int, input().split())))
for i in range(n):
    for j in range(i + 1, n):
        if checkdice(dice[i], dice[j]):
            msg = "No"
print(msg)

def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]


def checkdice(die1, die2):
    ans = False
    for d in "RRRNRRRNRRRSRRRSRRRNRRRR":
        if die1 == die2:
            ans = True
            break
        die2 = roll(die2, d)
    return ans


dice = []
msg = "Yes"
n = int(eval(input()))
for _ in range(n):
    dice.append(list(map(int, input().split())))
for i in range(n):
    for j in range(i + 1, n):
        if checkdice(dice[i], dice[j]):
            msg = "No"
            break
    if msg == "No":
        break
print(msg)

+            break +    if msg == "No": +        break