#include <bits/stdc++.h>
using namespace std;
int a[505][505];
long long dp[505][505];
long long fd[505][505];
long long dfs(int l, int r) {
  if (l > r) return 0;
  if (l == r) return 1;
  if (dp[l][r] != -1) return dp[l][r];
  if (l + 1 == r) return a[l][r];
  long long sum = 0;
  for (int i = l + 1; i <= r; i++) {
    if (a[l][i]) {
      if (fd[l][i] == -1) {
        fd[l][i] = 0;
        for (int j = l; j < i; j++)
          fd[l][i] = (fd[l][i] + (dfs(l, j) * dfs(j + 1, i) % 1000000007)) %
                     1000000007;
      }
      sum = (sum + fd[l][i] * dfs(i, r)) % 1000000007;
    }
  }
  dp[l][r] = sum;
  return sum;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  memset(dp, -1, sizeof(dp));
  memset(fd, -1, sizeof(fd));
  printf("%lld", dfs(1, n));
  return 0;
}
