#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int rows, columns;
    if (!(cin >> rows)) return 0;
    cin >> columns;

    const int cellCount = rows * columns;
    vector<int> value(cellCount);
    vector<vector<int>> cellsByProduct(cellCount + 1);

    for (int row = 1; row <= rows; ++row) {
        for (int column = 1; column <= columns; ++column) {
            const int index = (row - 1) * columns + column - 1;
            cin >> value[index];
            cellsByProduct[row * column].push_back(index);
        }
    }

    queue<int> pending;
    vector<char> visited(cellCount, false);
    pending.push(0);
    visited[0] = true;

    while (!pending.empty()) {
        const int index = pending.front();
        pending.pop();

        if (index == cellCount - 1) {
            cout << "yes\n";
            return 0;
        }

        const int jumpValue = value[index];
        if (jumpValue > cellCount) continue;

        for (const int next : cellsByProduct[jumpValue]) {
            if (!visited[next]) {
                visited[next] = true;
                pending.push(next);
            }
        }
        cellsByProduct[jumpValue].clear();
    }

    cout << "no\n";
    return 0;
}
