#include <bits/stdc++.h>
using namespace std;
const long long maxn = 510, mod = 1e9 + 7;
long long n, dp[maxn][maxn], open[maxn][maxn];
bool can[maxn][maxn];
signed Main() {
  cin >> n;
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) cin >> can[i][j];
  for (long long i = 1; i <= n; i++) dp[i][i] = 1;
  for (long long len = 2; len <= n; len++) {
    for (long long i = 1; i <= n - len + 1; i++) {
      long long j = i + len - 1;
      for (long long q = i; q < j; q++)
        open[i][j] = (open[i][j] + (dp[i][q] * dp[q + 1][j] % mod)) % mod;
      for (long long q = i + 1; q <= j; q++)
        if (can[i][q])
          dp[i][j] = (dp[i][j] + (open[i][q] * dp[q][j] % mod)) % mod;
    }
  }
  cout << dp[1][n] << '\n';
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  Main();
  cout << '\n';
  return 0;
}
