def check(x, y): 

    z = [0, 1, 2]

    for i in range(6):

        order = [0, 0, 0]

        for j in range(3):

            if {x[j], x[-j-1]} != {y[z[j]], y[-z[j]-1]}:

                break

            if x[j] == y[z[j]]:

                order[j] = 1 

                if x[j] == x[-j-1]:

                    order[j] = 2 

        else:

            if 2 in order or (i < 3) == sum(order) % 2:

                return True

        z = [z[2], z[0], z[1]]

        if i == 2:

            z = [z[0], z[2], z[1]]

    return False



n = int(eval(input()))

x = [[] for i in range(n)]

for i in range(n):

    x[i] = input().split()

for i in range(n):

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

        if check(x[i], x[j]):

            break

    else:

        continue

    print('No')

    break

else:

    print('Yes')
def check(x, y):

    for i in range(6):

        order = [0, 0, 0]

        for j in range(3):

            if {x[j], x[-j-1]} != {y[z[i][j]], y[-z[i][j]-1]}:

                break

            if x[j] == y[z[i][j]]:

                order[j] = 1

                if x[j] == x[-j-1]:

                    order[j] = 2

        else:

            if 2 in order or z[i][3] == sum(order) % 2:

                return True

    return False



n = int(eval(input()))

x = [[] for i in range(n)]

for i in range(n):

    x[i] = list(map(int, input().split()))

z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]]

different = True

for i in range(n):

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

        if check(x[i], x[j]):

            break

    else:

        continue

    print('No')

    break

else:

    print('Yes')
def check(x, y):
    z = [0, 1, 2]
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j - 1]} != {y[z[j]], y[-z[j] - 1]}:
                break
            if x[j] == y[z[j]]:
                order[j] = 1
                if x[j] == x[-j - 1]:
                    order[j] = 2
        else:
            if 2 in order or (i < 3) == sum(order) % 2:
                return True
        z = [z[2], z[0], z[1]]
        if i == 2:
            z = [z[0], z[2], z[1]]
    return False


n = int(eval(input()))
x = [[] for i in range(n)]
for i in range(n):
    x[i] = input().split()
for i in range(n):
    for j in range(i + 1, n, 1):
        if check(x[i], x[j]):
            break
    else:
        continue
    print("No")
    break
else:
    print("Yes")

def check(x, y):
    for i in range(6):
        order = [0, 0, 0]
        for j in range(3):
            if {x[j], x[-j - 1]} != {y[z[i][j]], y[-z[i][j] - 1]}:
                break
            if x[j] == y[z[i][j]]:
                order[j] = 1
                if x[j] == x[-j - 1]:
                    order[j] = 2
        else:
            if 2 in order or z[i][3] == sum(order) % 2:
                return True
    return False


n = int(eval(input()))
x = [[] for i in range(n)]
for i in range(n):
    x[i] = list(map(int, input().split()))
z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]]
different = True
for i in range(n):
    for j in range(i + 1, n, 1):
        if check(x[i], x[j]):
            break
    else:
        continue
    print("No")
    break
else:
    print("Yes")

-    z = [0, 1, 2] -            if {x[j], x[-j - 1]} != {y[z[j]], y[-z[j] - 1]}: +            if {x[j], x[-j - 1]} != {y[z[i][j]], y[-z[i][j] - 1]}: -            if x[j] == y[z[j]]: +            if x[j] == y[z[i][j]]: -            if 2 in order or (i < 3) == sum(order) % 2: +            if 2 in order or z[i][3] == sum(order) % 2: -        z = [z[2], z[0], z[1]] -        if i == 2: -            z = [z[0], z[2], z[1]] -    x[i] = input().split() +    x[i] = list(map(int, input().split())) +z = [[0, 1, 2, 1], [0, 2, 1, 0], [2, 1, 0, 0], [1, 0, 2, 0], [2, 0, 1, 1], [1, 2, 0, 1]] +different = True