#include <bits/stdc++.h>
using namespace std;
const int maxn = 505;
const long long mod = 1e9 + 7;
long long dp1[maxn][maxn], dp[maxn][maxn], a[maxn][maxn], n;
long long dfs(long long l, long long r);
long long dfs1(long long l, long long r);
long long dfs(long long l, long long r) {
  if (l == r) return dp[l][r] = 1;
  if (dp[l][r] != -1) return dp[l][r];
  long long ans = 0;
  for (int i = l + 1; i <= r; i++) {
    ans = (ans + dfs1(l, i) * dfs(i, r) % mod) % mod;
  }
  return dp[l][r] = ans;
}
long long dfs1(long long l, long long r) {
  if (!a[l][r]) return dp1[l][r] = 0;
  if (l == r) return dp1[l][r] = 1;
  if (dp1[l][r] != -1) return dp1[l][r];
  long long ans = 0;
  for (int i = l; i <= r - 1; i++) {
    ans = (ans + dfs(l, i) * dfs(i + 1, r) % mod) % mod;
  }
  return dp1[l][r] = ans;
}
int main() {
  memset(dp1, -1, sizeof(dp1));
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%lld", &a[i][j]);
    }
  }
  cout << dfs(1, n);
}
