#include <bits/stdc++.h>
using namespace std;
const double g = 10.0, eps = 1e-12;
const int N = 500 + 10, maxn = 123456 + 10, inf = 0x3f3f3f3f,
          INF = 0x3f3f3f3f3f3f3f3f;
long long dp[N][N][2];
int a[N][N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  for (int i = 0; i < n; i++) dp[i][i][0] = dp[i][i][1] = 1;
  for (int len = 2; len <= n; len++) {
    for (int i = 0, j = (i + len - 1) % n; j < n; j++, i++) {
      for (int k = i; k < j; k++) {
        if (a[i][j])
          dp[i][j][0] =
              (dp[i][j][0] + dp[i][k][1] * dp[k + 1][j][1]) % 1000000007;
        dp[i][j][1] =
            (dp[i][j][1] + dp[i][k + 1][0] * dp[k + 1][j][1]) % 1000000007;
      }
    }
  }
  printf("%lld\n", dp[0][n - 1][1]);
  return 0;
}
