#include
#include
#include
#include
int main(int argc, const char * argv[]) {
int red, kolona;
scanf("%d%d", &red, &kolona);
int mat[red][kolona];
for(int i = 0; i < red; i++) {
for(int j = 0; j < kolona; j++) {
scanf("%d", &mat[i][j]);
}
}
for(int i = 0; i < red - 1; i++) {
int najgolem_broj_vo_red_i = mat[i][0];
for(int j = 0; j < kolona; j++) {
if(mat[i][j] > najgolem_broj_vo_red_i) {
najgolem_broj_vo_red_i = mat[i][j];
}
}
for(int j = 0; j < kolona; j++) {
if(najgolem_broj_vo_red_i > mat[i + 1][j]) {
}
else {
printf("Ne vazhi vo redot: %d\n", i + 2);
return 0;
}
}
}
printf("DA\n");
return 0;
}
/*
5 4
1 2 10 0
7 2 3 1
8 0 5 4
4 1 0 1
2 3 0 0
**/