import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
{
Scanner in
= new Scanner
(System.
in); int m = in.nextInt(), n = in.nextInt();
double[][] M = new double[m][n];
boolean[] monotone = new boolean[m];
for (int i = 0; i < m; i++)
for (int j = 0; j < n; j++)
M[i][j] = in.nextDouble();
for (int i = 0; i < m; i++) {
boolean check = true, diff;
if (M[i][0] != M[i][1]) {
diff = (M[i][1] > M[i][0]);
for (int j = 2; j < n; j++)
if ((M[i][j] == M[i][j-1]) || ((M[i][j] > M[i][j-1]) != diff)) {
check = false;
break;
}
}
else
check = false;
monotone[i] = check;
}
for (int i = 0; i < m; i++)
System.
out.
println(monotone
[i
]); }
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBNYWluCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCVNjYW5uZXIgaW4gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwoJCWludCBtID0gaW4ubmV4dEludCgpLCBuID0gaW4ubmV4dEludCgpOwoJCWRvdWJsZVtdW10gTSA9IG5ldyBkb3VibGVbbV1bbl07CgkJYm9vbGVhbltdIG1vbm90b25lID0gbmV3IGJvb2xlYW5bbV07CgkJCgkJZm9yIChpbnQgaSA9IDA7IGkgPCBtOyBpKyspCgkJCWZvciAoaW50IGogPSAwOyBqIDwgbjsgaisrKQoJCQkJTVtpXVtqXSA9IGluLm5leHREb3VibGUoKTsKCQkKCQlmb3IgKGludCBpID0gMDsgaSA8IG07IGkrKykgewoJCQlib29sZWFuIGNoZWNrID0gdHJ1ZSwgZGlmZjsKCQkJaWYgKE1baV1bMF0gIT0gTVtpXVsxXSkgewoJCQkJZGlmZiA9IChNW2ldWzFdID4gTVtpXVswXSk7CgkJCQlmb3IgKGludCBqID0gMjsgaiA8IG47IGorKykKCQkJCQlpZiAoKE1baV1bal0gPT0gTVtpXVtqLTFdKSB8fCAoKE1baV1bal0gPiBNW2ldW2otMV0pICE9IGRpZmYpKSB7CgkJCQkJCWNoZWNrID0gZmFsc2U7CgkJCQkJCWJyZWFrOwoJCQkJCX0KCQkJfQoJCQllbHNlCgkJCQljaGVjayA9IGZhbHNlOwoJCQltb25vdG9uZVtpXSA9IGNoZWNrOwoJCX0KCQkKCQlmb3IgKGludCBpID0gMDsgaSA8IG07IGkrKykKCQkJU3lzdGVtLm91dC5wcmludGxuKG1vbm90b25lW2ldKTsKCX0KfQ==