#include <bits/stdc++.h>
using namespace std;
const int N = 505, mod = 1e9 + 7;
int n, m, e[N][N], f[N][N], g[N][N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (n); j++) cin >> e[i][j];
  for (int i = (1); i <= (n); i++) g[i][i] = f[i][i] = 1;
  for (int len = (1); len <= (n); len++)
    for (int l = (1); l <= (n - len + 1); l++) {
      int r = l + len - 1;
      for (int k = (l); k <= (r - 1); k++)
        if (e[l][r]) (g[l][r] += (long long)f[l][k] * f[k + 1][r] % mod) %= mod;
      for (int k = (l + 1); k <= (r); k++)
        (f[l][r] += (long long)g[l][k] * f[k][r] % mod) %= mod;
    }
  cout << f[1][n] << '\n';
  return 0;
}
