#include<iostream>
using namespace std;
const int dy[] = { 0, 1, -1, 0}, dx[] = { 1, 0, 0, -1};
int n, mas[8][8];
bool used[8][8];
bool isover( int& y, int& x){
  return x < 0 || y < 0 || x >= n || y >= n;
}
bool dfs( int hoge, int y, int x, int sum){
  if(hoge == 0 && sum == n * n) return true;
  bool ret = false;
  if(hoge < 0){
    for(int i = 0 ; i < 4 ; i++ ){
      int ny = y + dy[i], nx = x + dx[i];
      if(!isover(ny,nx) && mas[ny][nx] > 0 && !used[ny][nx]){
        used[ny][nx] = true;
        ret += dfs( hoge + mas[ny][nx], ny, nx, sum + 1);
        used[ny][nx] = false;
      }
    }
  }else if(!hoge){
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < n ; j++ ){
        if(mas[i][j] < 0 && !used[i][j]){
          used[i][j] = true;
          ret += dfs( mas[i][j], i, j, sum + 1);
          used[i][j] = false;
          return ret;
        }
      }
    }
  }
  return ret;
}
int main(){
  while(cin >> n , n){
    for(int i = 0 ; i < n ; i++ ){
      for(int j = 0 ; j < n ; j++ ){
        cin >> mas[i][j];
      }
    }
    cout << (dfs(0,0,0,0) ? "YES" : "NO") << endl;
  }
}