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

typedef pair<int,int> P;

int n;
int t[10][10];
long long v;
map<long long,bool> m;
vector<P> can;
int dy[] = {-1,0,1,0} , dx[] = {0,1,0,-1};

bool rec(int id);

bool dfs(int id,int y,int x,int sum){
  if(sum == 0)return rec(id+1);
  if(sum>0)return false;

  for(int i=0;i<4;i++){
    int ty = y+dy[i], tx = x+dx[i];
    if(ty<0 || tx<0 || n<=ty || n<= tx)continue;
    if( (v>>(ty*n+tx)) & 1LL || t[ty][tx]<0)continue;
    v |= 1LL << (ty*n+tx);
    if(dfs(id,ty,tx,sum+t[ty][tx]))return true;
    v &= ~(1LL << (ty*n+tx));
  }
  return false;
}

bool rec(int id){
  if(id == can.size())return true;
  if(m[v])return false;
  m[v] = true;
  int y = can[id].first, x = can[id].second;
  return dfs(id,y,x,t[y][x]);
}

int main(){
  while(cin >> n,n){
    int sum = 0; can.clear(); m.clear();
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++){
	cin >> t[i][j];
	sum += t[i][j];
	if(t[i][j]<0){
	  can.push_back(P(i,j));
	  v |= 1LL<<(i*n+j);
	}
      }
    v = 0LL;

    cout << ( (!sum && rec(0))?"YES\n":"NO\n" );
  }
}