#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
int n;
int A[506];
int G[506][506];
int dp[506][506], pd[506][506];
void solve() {
  cin >> n;
  for (int i = (1), iend = (n); i <= iend; ++i)
    for (int j = (1), jend = (n); j <= jend; ++j) scanf("%d", &G[i][j]);
  for (int i = (1), iend = (n); i <= iend; ++i) dp[i][i] = 1;
  for (int len = (2), lenend = (n); len <= lenend; ++len)
    for (int i = (1), iend = (n - len + 1); i <= iend; ++i) {
      int j = i + len - 1;
      if (G[i][j])
        for (int k = (i), kend = (j - 1); k <= kend; ++k)
          pd[i][j] = (pd[i][j] + dp[i][k] * 1ll * dp[k + 1][j]) % P;
      for (int k = (i + 1), kend = (j); k <= kend; ++k)
        dp[i][j] = (dp[i][j] + pd[i][k] * 1ll * dp[k][j]) % P;
    }
  printf("%d\n", dp[1][n]);
}
signed main() { solve(); }
