#include <bits/stdc++.h>
using namespace std;
const long long P = 1000000007;
int n;
int a[505][505];
long long dp0[505][505], dp1[505][505];
long long dfs0(int l, int r);
long long dfs1(int l, int r);
long long dfs0(int l, int r) {
  int k;
  if (l == r) return dp0[l][r] = 1;
  if (dp0[l][r] >= 0) return dp0[l][r];
  dp0[l][r] = 0;
  for (k = l + 1; k <= r; k++) {
    long long tmp = (dfs1(l, k) * dfs0(k, r)) % P;
    dp0[l][r] = (dp0[l][r] + tmp) % P;
  }
  return dp0[l][r];
}
long long dfs1(int l, int r) {
  int k;
  if (!a[l][r]) return dp1[l][r] = 0;
  if (l == r) return dp1[l][r] = 1;
  if (dp1[l][r] >= 0) return dp1[l][r];
  dp1[l][r] = 0;
  for (k = l; k < r; k++) {
    long long tmp = (dfs0(l, k) * dfs0(k + 1, r)) % P;
    dp1[l][r] = (dp1[l][r] + tmp) % P;
  }
  return dp1[l][r];
}
int main() {
  int i, j;
  cin >> n;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) cin >> a[i][j];
  for (i = 1; i <= n; i++) a[i][i] = 1;
  memset(dp0, -1, sizeof(dp0));
  memset(dp1, -1, sizeof(dp1));
  cout << dfs0(1, n) << endl;
  return 0;
}
