#include <bits/stdc++.h>
using namespace std;
int const MOD = (int)1e9 + 7;
int n;
int a[505][505];
int f[505][505];
int g[505][505];
int main(int argc, char* argv[]) {
  ::std::ios::sync_with_stdio(false);
  ::std::cin.tie(0);
  ::std::cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> a[i][j];
  for (int i = 0; i < n; i++) f[i][i] = g[i][i] = 1;
  for (int l = 2; l <= n; l++) {
    for (int i = 0; i < n; i++) {
      int j = (i + l - 1) % n;
      if (a[i][j]) {
        for (int k = i; k != j; k = (k + 1) % n) {
          g[i][j] = (g[i][j] + 1ll * f[i][k] * f[(k + 1) % n][j]) % MOD;
        }
      }
      for (int k = i; k != j; k = (k + 1) % n) {
        f[i][j] = (f[i][j] + 1ll * f[i][k] * g[k][j]) % MOD;
      }
    }
  }
  cout << f[0][n - 1] << endl;
}
