#include <bits/stdc++.h>
using namespace std;
inline long long mod(long long n, long long m) {
  long long ret = n % m;
  if (ret < 0) ret += m;
  return ret;
}
long long gcd(long long a, long long b) {
  return (b == 0LL ? a : gcd(b, a % b));
}
long long exp(long long a, long long b, long long m) {
  if (b == 0LL) return 1LL;
  if (b == 1LL) return mod(a, m);
  long long k = mod(exp(a, b / 2, m), m);
  if (b & 1LL) {
    return mod(a * mod(k * k, m), m);
  } else
    return mod(k * k, m);
}
const int N = 1010;
int a[N][N];
int dp[N][N][2];
const int M = 1e9 + 7;
int n;
int solve(int l, int r, int f) {
  if (r - l <= 1) return 1;
  int& x = dp[l][r][f];
  if (x != -1) return x;
  x = 0;
  if (f == 0) x = solve(l, r, 1);
  for (int k = l + 1; k < r; k++) {
    if (f == 1) {
      if (a[r][k]) x = (x + 1ll * solve(l, k, 1) * solve(k, r, 0)) % M;
    } else {
      if (a[l][k]) x = (x + 1ll * solve(l, k, 0) * solve(k, r, 0)) % M;
    }
  }
  return x;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> a[i][j];
      a[i + n][j] = a[i][j + n] = a[i + n][j + n] = a[i][j];
    }
  }
  long long res = 0;
  res += solve(1, n + 1, 1);
  cout << res << "\n";
}
