#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<vector<vector<int>>> dp(n + 1,
                                 vector<vector<int>>(n + 1, vector<int>(2, 0)));
  vector<vector<int>> a(n + 1, vector<int>(n + 1, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    dp[i][i][0] = dp[i][i][1] = 1;
    if (i < n - 1) dp[i][i + 1][0] = dp[i][i + 1][1] = a[i][i + 1];
  }
  for (int len = 2; len < n; len++) {
    for (int i = 0; i + len < n; i++) {
      int j = i + len;
      if (a[i][j])
        for (int k = i; k < j; k++) {
          dp[i][j][1] += (dp[i][k][0] * 1ll * dp[k + 1][j][0]) % mod;
          if (dp[i][j][1] >= mod) dp[i][j][1] -= mod;
        }
      for (int k = i + 1; k <= j; k++) {
        dp[i][j][0] += (dp[i][k][1] * 1ll * dp[k][j][0]) % mod;
        if (dp[i][j][0] >= mod) dp[i][j][0] -= mod;
      }
    }
  }
  cout << dp[0][n - 1][0] << "\n";
  return 0;
}
