//最后一定全变成0,每两个直接相邻的数一定只能变成他俩中间的数,所以每两个相邻的数 组成的区间必须包含0.
//满足该条件后,每个数字必定可以增加或减少变成0.并且与操作顺序无关,必定能操作。


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

int main() {
    int n;
    cin >> n;
    vector<vector<int>> a(n,vector<int>(n));
    for(auto &k:a)
        for(auto &k:k)
            cin >> k;

    bool ok = true;
    for(int i = 0;i < n;++i)
        for(int j = 0;j < n;++j)
        {
            if(i + 1 < n && 1LL*a[i + 1][j]*a[i][j] > 0)
                ok = false;
            
            if(j + 1 < n && 1LL*a[i][j+1]*a[i][j] > 0)
                ok = false;
        }
    cout << (ok? "YES" : "NO") << "\n";
}
// 64 位输出请用 printf("%lld")