function Dice( faces ) {
  this.faces = faces;
  this.getFace = function ( id ) {
    return this.faces[id];
  }
  this.roll = function ( cmds ) {
    var t;
    for( var i=0; i<cmds.length; i++ ) {
      if( 'E' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = t;
      } else if( 'S' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = t;
      } else if( 'W' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = t;
      } else if( 'N' == cmds[i] ) {
        t = this.faces[Dice.TOP];
        this.faces[Dice.TOP] = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = this.faces[Dice.BOTTOM];
        this.faces[Dice.BOTTOM] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = t;        
      } else if( 'M' == cmds[i] ) {
        t = this.faces[Dice.FRONT];
        this.faces[Dice.FRONT] = this.faces[Dice.RIGHT];
        this.faces[Dice.RIGHT] = this.faces[Dice.BACK];
        this.faces[Dice.BACK] = this.faces[Dice.LEFT];
        this.faces[Dice.LEFT] = t;        
      }
    }
  }
  
  this.isEqual = function( other ) {
    var cmds = "NWWWNMMMM";
    var isequal = false;
    for( var i=0; i<cmds.length && !isequal; i++ ) {
      if( other.getFace( Dice.TOP ) == this.getFace( Dice.TOP ) ) {
        var j;
        for( j=5; j<cmds.length && !isequal; j++ ) {
          if( other.getFace( Dice.FRONT ) == this.getFace( Dice.FRONT ) ) {
            var k;
            for( k=Dice.TOP; k<=Dice.BOTTOM; k++ ) {
              if( this.getFace( k ) != other.getFace( k ) ) { break; }
            }
            isequal = (k==6)?true:false;
          }
          other.roll( cmds[j] );
        }
      }
      other.roll( cmds[i] );
    }
    return isequal;
  }
}
Dice.TOP = 0;
Dice.FRONT = 1;
Dice.RIGHT = 2;
Dice.LEFT = 3;
Dice.BACK = 4;
Dice.BOTTOM = 5;

var input = '';
var readable = process.stdin;
readable.resume();
readable.setEncoding( 'utf-8' );
readable.on( 'data', function( chunk ) {
  input += chunk;
});

readable.on( 'end', function() {
  var data = input.split( '\n' );
  var n = parseInt( data[0] );
  var dices = [];
  for( var i=1; i<=n; i++ ) {
    dices.push( new Dice( data[i].split( ' ' ).map( Number ) ) );
  }
  
  var isequal = false;
  for( var i=0; i<n-1 && !isequal; i++ ) {
    for( var j=i+1; j<n && !isequal; j++ ) {
      isequal = dices[i].isEqual( dices[j] );
    }
  }
  if( isequal ) {
    console.log( "No" );
  } else {
    console.log( "Yes" );
  }
});