#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int n;
int a[505][505];
long long dp[505][505][2];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      dp[i][i][0] = 1;
    }
  for (int i = 2; i <= n; i++) {
    for (int l = 1; l + i - 1 <= n; l++) {
      int r = l + i - 1;
      if (a[l][r])
        for (int cut = l; cut < r; cut++)
          dp[l][r][0] += (dp[l][cut][0] + dp[l][cut][1]) % MOD *
                         (dp[cut + 1][r][0] + dp[cut + 1][r][1]) % MOD,
              dp[l][r][0] %= MOD;
      for (int cut = l + 1; cut < r; cut++)
        if (a[l][cut])
          dp[l][r][1] +=
              dp[l][cut][0] % MOD * (dp[cut][r][0] + dp[cut][r][1]) % MOD,
              dp[l][r][1] %= MOD;
    }
  }
  cout << (dp[1][n][0] + dp[1][n][1]) % MOD;
}
