#include<bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i = 0; i < n; i++)

bool dfs(int, int);
bool dfs2( int, int, const int, const int, int);

int n, number[8][8];
const int dy[] = { 0, 1, 0, -1}, dx[] = { 1, 0, -1, 0};


bool dfs2(int x, int y, const int basex, const int basey, int sub){


  if(sub < 0) return false;
  if(sub == 0) return dfs( basex + 1, basey);

  Rep(i,4){
    int ny = y + dy[i], nx = x + dx[i];
    if(ny < 0 || ny >= n || nx < 0 || nx >= n || number[ny][nx] <= 0) continue;
    int next = number[ny][nx];
    number[ny][nx] = 0;
    if(dfs2( nx, ny, basex, basey, sub - next)) return true;
    number[ny][nx] = next;
  }
  return false;
}

bool dfs(int x, int y){

  if(y == n){
    Rep(i,n) Rep(j,n) if(number[i][j] != 0) return false;
    return true;
  }
  if(x == n) return dfs( 0, y + 1);
  if(number[y][x] >= 0) return dfs( x + 1, y);
  else{
    int prev = number[y][x];
    number[y][x] = 0;
    if(dfs2( x, y, x, y, -prev)) return true;
    number[y][x] = prev;
  }
  return false;
}

int main(){
  while(cin >> n, n){

    int ret = 0;
    
    Rep(i,n){
      Rep(j,n){
        cin >> number[i][j];
        ret += number[i][j];
      }
    }
    if(ret == 0 && dfs(0,0)) puts("YES");
    else puts("NO");
  }
}