import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Scanner;
public class Main {
public static void main
(String[] args
) { }
private Scanner scanner;
this.scanner = new Scanner(is);
}
public void solve() {
int rowCount = scanner.nextInt();
int columnCount = scanner.nextInt();
int[][] chocolate = new int[rowCount][columnCount];
for (int i = 0; i < rowCount; i++) {
for (int j = 0; j < columnCount; j++) chocolate[i][j] = scanner.nextInt();
}
check(chocolate, rowCount, columnCount);
writer.flush(); writer.close();
}
private void check(int[][] chocolate, int rowCount, int columnCount) {
if (mayBreakByRow(chocolate, rowCount, columnCount) || mayBreakByColumn(chocolate, rowCount, columnCount)) writer.println("Yes");
else writer.println("No");
}
private boolean mayBreakByRow(int[][] chocolate, int rowCount, int columnCount) {
for (int i = 0; i < rowCount - 1; i++) {
boolean okRow = true;
for (int j = 0; j < columnCount; j++) {
if (chocolate[i][j] == chocolate[i + 1][j]) { okRow = false; break; }
}
if (okRow) return true;
}
return false;
}
private boolean mayBreakByColumn(int[][] chocolate, int rowCount, int columnCount) {
for (int i = 0; i < columnCount - 1; i++) {
boolean okColumn = true;
for (int j = 0; j < rowCount; j++) {
if (chocolate[j][i] == chocolate[j][i + 1]) { okColumn = false; break; }
}
if (okColumn) return true;
}
return false;
}
}
}
aW1wb3J0IGphdmEuaW8uSW5wdXRTdHJlYW07CmltcG9ydCBqYXZhLmlvLk91dHB1dFN0cmVhbTsKaW1wb3J0IGphdmEuaW8uUHJpbnRXcml0ZXI7CmltcG9ydCBqYXZhLnV0aWwuU2Nhbm5lcjsKCnB1YmxpYyBjbGFzcyBNYWluIHsKCiAgICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB7CiAgICAgICAgbmV3IFJlc29sdmVyKFN5c3RlbS5pbiwgU3lzdGVtLm91dCkuc29sdmUoKTsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIGNsYXNzIFJlc29sdmVyIHsKCiAgICAgICAgcHJpdmF0ZSBTY2FubmVyIHNjYW5uZXI7CiAgICAgICAgcHJpdmF0ZSBQcmludFdyaXRlciB3cml0ZXI7CgogICAgICAgIHB1YmxpYyBSZXNvbHZlcihJbnB1dFN0cmVhbSBpcywgT3V0cHV0U3RyZWFtIG9zKSB7CiAgICAgICAgICAgIHRoaXMuc2Nhbm5lciA9IG5ldyBTY2FubmVyKGlzKTsKICAgICAgICAgICAgdGhpcy53cml0ZXIgPSBuZXcgUHJpbnRXcml0ZXIob3MpOwogICAgICAgIH0KCiAgICAgICAgcHVibGljIHZvaWQgc29sdmUoKSB7CiAgICAgICAgICAgIGludCByb3dDb3VudCA9IHNjYW5uZXIubmV4dEludCgpOwogICAgICAgICAgICBpbnQgY29sdW1uQ291bnQgPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICAgICAgaW50W11bXSBjaG9jb2xhdGUgPSBuZXcgaW50W3Jvd0NvdW50XVtjb2x1bW5Db3VudF07CiAgICAgICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcm93Q291bnQ7IGkrKykgewogICAgICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBjb2x1bW5Db3VudDsgaisrKSBjaG9jb2xhdGVbaV1bal0gPSBzY2FubmVyLm5leHRJbnQoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjaGVjayhjaG9jb2xhdGUsIHJvd0NvdW50LCBjb2x1bW5Db3VudCk7CiAgICAgICAgICAgIHdyaXRlci5mbHVzaCgpOyB3cml0ZXIuY2xvc2UoKTsKICAgICAgICB9CgogICAgICAgIHByaXZhdGUgdm9pZCBjaGVjayhpbnRbXVtdIGNob2NvbGF0ZSwgaW50IHJvd0NvdW50LCBpbnQgY29sdW1uQ291bnQpIHsKICAgICAgICAgICAgaWYgKG1heUJyZWFrQnlSb3coY2hvY29sYXRlLCByb3dDb3VudCwgY29sdW1uQ291bnQpIHx8IG1heUJyZWFrQnlDb2x1bW4oY2hvY29sYXRlLCByb3dDb3VudCwgY29sdW1uQ291bnQpKSB3cml0ZXIucHJpbnRsbigiWWVzIik7CiAgICAgICAgICAgIGVsc2Ugd3JpdGVyLnByaW50bG4oIk5vIik7CiAgICAgICAgfQogICAgICAgIHByaXZhdGUgYm9vbGVhbiBtYXlCcmVha0J5Um93KGludFtdW10gY2hvY29sYXRlLCBpbnQgcm93Q291bnQsIGludCBjb2x1bW5Db3VudCkgewogICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IHJvd0NvdW50IC0gMTsgaSsrKSB7CiAgICAgICAgICAgICAgICBib29sZWFuIG9rUm93ID0gdHJ1ZTsKICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgY29sdW1uQ291bnQ7IGorKykgewogICAgICAgICAgICAgICAgICAgIGlmIChjaG9jb2xhdGVbaV1bal0gPT0gY2hvY29sYXRlW2kgKyAxXVtqXSkgeyBva1JvdyA9IGZhbHNlOyBicmVhazsgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG9rUm93KSByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgICAgIHByaXZhdGUgYm9vbGVhbiBtYXlCcmVha0J5Q29sdW1uKGludFtdW10gY2hvY29sYXRlLCBpbnQgcm93Q291bnQsIGludCBjb2x1bW5Db3VudCkgewogICAgICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IGNvbHVtbkNvdW50IC0gMTsgaSsrKSB7CiAgICAgICAgICAgICAgICBib29sZWFuIG9rQ29sdW1uID0gdHJ1ZTsKICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgcm93Q291bnQ7IGorKykgewogICAgICAgICAgICAgICAgICAgIGlmIChjaG9jb2xhdGVbal1baV0gPT0gY2hvY29sYXRlW2pdW2kgKyAxXSkgeyBva0NvbHVtbiA9IGZhbHNlOyBicmVhazsgfQogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgaWYgKG9rQ29sdW1uKSByZXR1cm4gdHJ1ZTsKICAgICAgICAgICAgfQogICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgfQogICAgfQp9