#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
long long inv(long long x) { return x <= 1 ? 1 : inv(P % x) * (P - P / x) % P; }
const int N = 555;
struct _ {
  int f = -1, g = 0;
} dp[N][N];
int a[N][N], n;
_ dfs(int l, int r) {
  _ &ans = dp[l][r];
  if (~ans.f) return ans;
  ans.f = ans.g = 0;
  bool ok = l == 0 && r == 1;
  for (int x = l;; x = (x + 1) % n) {
    if (a[l][r] && x != r)
      (ans.g += (long long)dfs(l, x).f * dfs((x + 1) % n, r).f % P) %= P;
    if (x != l) (ans.f += (long long)dfs(l, x).g * dfs(x, r).f % P) %= P;
    if (x == r) break;
  }
  return ans;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= n - 1; ++i)
    for (int j = 0; j <= n - 1; ++j)
      scanf("%d", &a[i][j]), dp[i][i].f = dp[i][j].g = 1;
  printf("%d\n", dfs(0, n - 1).f);
}
