#include <bits/stdc++.h>
using namespace std;
const int N = 5e2 + 5;
const int MOD = 1e9 + 7;
long long dp[N][N][2], dat[N][N], n;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> dat[i][j];
  for (int i = 0; i < n; i++) dp[i][i][0] = 0, dp[i][i][1] = 1;
  for (int len = 2; len <= n; len++) {
    for (int l = 0; l <= n - len; l++) {
      int r = l + len - 1;
      if (dat[l][r]) {
        for (int x = l; x < r; x++)
          dp[l][r][0] = (dp[l][r][0] + dp[l][x][1] * dp[x + 1][r][1]) % MOD;
      }
      for (int x = l; x < r; x++)
        dp[l][r][1] = (dp[l][r][1] + dp[l][x][1] * dp[x][r][0]) % MOD;
    }
  }
  cout << dp[0][n - 1][1] << "\n";
  return 0;
}
