import java.util.* ;
public class Main {
public static void main
( String [ ] args
) { Scanner sc
= new Scanner
( System .
in ) ; int n = sc.nextInt ( ) ;
short [ ] [ ] graph = new short [ n] [ n] ;
for ( int i = 0 ; i < n; i++ ) {
for ( int j = 0 ; j < n; j++ ) {
graph[ i] [ j] = sc.nextShort ( ) ;
}
}
for ( int i = 0 ; i < n; i++ ) {
for ( int j = 0 ; j < n; j++ ) {
if ( graph[ i] [ j] == 1 ) {
for ( int z = 0 ; z < n; z++ ) {
if ( graph[ j] [ z] == 1 && graph[ i] [ z] == 0 ) {
answer = "NO" ;
break ;
}
}
}
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwpwdWJsaWMgY2xhc3MgTWFpbiB7CiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgU2Nhbm5lciBzYyA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CiAgICAgICAgaW50IG4gPSBzYy5uZXh0SW50KCk7CiAgICAgICAgU3RyaW5nIGFuc3dlciA9ICJZRVMiOwogICAgICAgIHNob3J0W11bXSBncmFwaCA9IG5ldyBzaG9ydCBbbl1bbl07CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgICAgICAgICAgZm9yKCBpbnQgaiA9IDA7IGogPCBuOyBqKyspIHsKICAgICAgICAgICAgICAgIGdyYXBoW2ldW2pdID0gc2MubmV4dFNob3J0KCk7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgZm9yKGludCBpID0gMDsgaSA8IG47IGkrKyl7CiAgICAgICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBuOyBqKyspewogICAgICAgICAgICAgICAgaWYgKGdyYXBoW2ldW2pdID09IDEpeyAKICAgICAgICAgICAgICAgICAgICBmb3IgKGludCB6ID0gMDsgeiA8IG47IHorKyl7CiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChncmFwaFtqXVt6XSA9PSAxICYmIGdyYXBoW2ldW3pdID09IDApIHsgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICBhbnN3ZXIgPSAiTk8iOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICAgICAgICAgIH0gICAKICAgICAgICAgICAgICAgICAgICB9ICAgCiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICBTeXN0ZW0ub3V0LnByaW50KGFuc3dlcik7CiAgICB9CiAgICAKfQo=