#include <bits/stdc++.h>
using namespace std;
const int NN = 555;
const int mod = 1e9 + 7;
int a[NN][NN];
int dp[NN][NN][2];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) cin >> a[i][j];
  }
  for (int i = 1; i <= n; i++) dp[i][i][0] = 1;
  for (int len = 1; len <= n; len++) {
    for (int i = 1; i <= n; i++) {
      int j = i + len;
      if (j > n) break;
      for (int k = i + 1; k < j; k++) {
        if (a[i][k]) {
          dp[i][j][0] =
              (dp[i][j][0] + 1LL * dp[i][k][1] * dp[k][j][0] % mod) % mod;
          dp[i][j][1] =
              (dp[i][j][1] + 1LL * dp[i][k][1] * dp[k][j][1] % mod) % mod;
        }
      }
      dp[i][j][1] = (dp[i][j][1] + dp[i + 1][j][0]) % mod;
      if (a[i][j]) dp[i][j][0] = (dp[i][j][0] + dp[i][j][1]) % mod;
    }
  }
  cout << dp[1][n][0] << endl;
  return 0;
}
