import copy, sys



class Dice(object):

    def __init__(self, nums):

        self.top, self.front, self.right, self.left, self.back, self.bottom = nums



    def roll(self, directions):

        if directions == 'E':

            self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right

            return



        if directions == 'N':

            self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back

            return



        if directions == 'S':

            self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front

            return



        if directions == 'W':

            self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left

            return



        self.roll(directions[0])

        self.roll(directions[1:])



    def equal(self, dice):

        d = copy.copy(self)



        if(dice.front == d.top):

            d.roll('S')

        elif(dice.front == d.right):

            d.roll('WS')

        elif(dice.front == d.left):

            d.roll('ES')

        elif(dice.front == d.back):

            d.roll('SS')

        elif(dice.front == d.bottom):

            d.roll('N')



        if(dice.top == d.right):

            d.roll('W')

        elif(dice.top == d.left):

            d.roll('E')

        elif(dice.top == d.bottom):

            d.roll('WW')



        return not(dice.top != d.top or dice.front != d.front or dice.right != d.right or dice.left != d.left or dice.back != d.back or dice.bottom != d.bottom)



if __name__ == '__main__':

    n = int(eval(input()))

    dices = []

    for i in range(n):

        d = Dice([int(_) for _ in input().split()])

        for dice in dices:

            if d.equal(dice):

                print('No')

                sys.exit()

        dices.append(d)

    print('Yes')
import copy, sys



class Dice(object):

    def __init__(self, nums):

        self.top, self.front, self.right, self.left, self.back, self.bottom = nums



    def roll(self, directions):

        if directions == 'E':

            self.top, self.right, self.left, self.bottom = self.left, self.top, self.bottom, self.right

            return



        if directions == 'N':

            self.top, self.front, self.back, self.bottom = self.front, self.bottom, self.top, self.back

            return



        if directions == 'S':

            self.top, self.front, self.back, self.bottom = self.back, self.top, self.bottom, self.front

            return



        if directions == 'W':

            self.top, self.right, self.left, self.bottom = self.right, self.bottom, self.top, self.left

            return



        self.roll(directions[0])

        self.roll(directions[1:])



    def equal(self, dice):

        d = copy.copy(self)



        if(dice.front == d.top):

            d.roll('S')

        elif(dice.front == d.right):

            d.roll('WS')

        elif(dice.front == d.left):

            d.roll('ES')

        elif(dice.front == d.back):

            d.roll('SS')

        elif(dice.front == d.bottom):

            d.roll('N')



        if(dice.top == d.right):

            d.roll('W')

        elif(dice.top == d.left):

            d.roll('E')

        elif(dice.top == d.bottom):

            d.roll('WW')



        return not(dice.top != d.top or dice.front != d.front or dice.right != d.right or dice.left != d.left or dice.back != d.back or dice.bottom != d.bottom)



if __name__ == '__main__':

    n = int(eval(input()))

    dices = [[] for _ in range(600)]

    for i in range(n):

        nums = [int(_) for _ in input().split()]

        d = Dice(nums)

        s = sum(nums)

        for dice in dices[s]:

            if d.equal(dice):

                print('No')

                sys.exit()

        dices[s].append(d)

    print('Yes')
import copy, sys


class Dice(object):
    def __init__(self, nums):
        self.top, self.front, self.right, self.left, self.back, self.bottom = nums

    def roll(self, directions):
        if directions == "E":
            self.top, self.right, self.left, self.bottom = (
                self.left,
                self.top,
                self.bottom,
                self.right,
            )
            return
        if directions == "N":
            self.top, self.front, self.back, self.bottom = (
                self.front,
                self.bottom,
                self.top,
                self.back,
            )
            return
        if directions == "S":
            self.top, self.front, self.back, self.bottom = (
                self.back,
                self.top,
                self.bottom,
                self.front,
            )
            return
        if directions == "W":
            self.top, self.right, self.left, self.bottom = (
                self.right,
                self.bottom,
                self.top,
                self.left,
            )
            return
        self.roll(directions[0])
        self.roll(directions[1:])

    def equal(self, dice):
        d = copy.copy(self)
        if dice.front == d.top:
            d.roll("S")
        elif dice.front == d.right:
            d.roll("WS")
        elif dice.front == d.left:
            d.roll("ES")
        elif dice.front == d.back:
            d.roll("SS")
        elif dice.front == d.bottom:
            d.roll("N")
        if dice.top == d.right:
            d.roll("W")
        elif dice.top == d.left:
            d.roll("E")
        elif dice.top == d.bottom:
            d.roll("WW")
        return not (
            dice.top != d.top
            or dice.front != d.front
            or dice.right != d.right
            or dice.left != d.left
            or dice.back != d.back
            or dice.bottom != d.bottom
        )


if __name__ == "__main__":
    n = int(eval(input()))
    dices = []
    for i in range(n):
        d = Dice([int(_) for _ in input().split()])
        for dice in dices:
            if d.equal(dice):
                print("No")
                sys.exit()
        dices.append(d)
    print("Yes")

import copy, sys


class Dice(object):
    def __init__(self, nums):
        self.top, self.front, self.right, self.left, self.back, self.bottom = nums

    def roll(self, directions):
        if directions == "E":
            self.top, self.right, self.left, self.bottom = (
                self.left,
                self.top,
                self.bottom,
                self.right,
            )
            return
        if directions == "N":
            self.top, self.front, self.back, self.bottom = (
                self.front,
                self.bottom,
                self.top,
                self.back,
            )
            return
        if directions == "S":
            self.top, self.front, self.back, self.bottom = (
                self.back,
                self.top,
                self.bottom,
                self.front,
            )
            return
        if directions == "W":
            self.top, self.right, self.left, self.bottom = (
                self.right,
                self.bottom,
                self.top,
                self.left,
            )
            return
        self.roll(directions[0])
        self.roll(directions[1:])

    def equal(self, dice):
        d = copy.copy(self)
        if dice.front == d.top:
            d.roll("S")
        elif dice.front == d.right:
            d.roll("WS")
        elif dice.front == d.left:
            d.roll("ES")
        elif dice.front == d.back:
            d.roll("SS")
        elif dice.front == d.bottom:
            d.roll("N")
        if dice.top == d.right:
            d.roll("W")
        elif dice.top == d.left:
            d.roll("E")
        elif dice.top == d.bottom:
            d.roll("WW")
        return not (
            dice.top != d.top
            or dice.front != d.front
            or dice.right != d.right
            or dice.left != d.left
            or dice.back != d.back
            or dice.bottom != d.bottom
        )


if __name__ == "__main__":
    n = int(eval(input()))
    dices = [[] for _ in range(600)]
    for i in range(n):
        nums = [int(_) for _ in input().split()]
        d = Dice(nums)
        s = sum(nums)
        for dice in dices[s]:
            if d.equal(dice):
                print("No")
                sys.exit()
        dices[s].append(d)
    print("Yes")

-    dices = [] +    dices = [[] for _ in range(600)] -        d = Dice([int(_) for _ in input().split()]) -        for dice in dices: +        nums = [int(_) for _ in input().split()] +        d = Dice(nums) +        s = sum(nums) +        for dice in dices[s]: -        dices.append(d) +        dices[s].append(d)