#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
long long POW(long long a, long long b, long long MMM = MOD) {
  long long ret = 1;
  for (; b; b >>= 1, a = (a * a) % MMM)
    if (b & 1) ret = (ret * a) % MMM;
  return ret;
}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, 1, -1};
int ddx[] = {-1, -2, 1, -2, 2, -1, 2, 1}, ddy[] = {-2, -1, -2, 1, -1, 2, 1, 2};
int a[505][505], n;
long long d[505][505][2];
long long go(int L, int R, int c) {
  if (L + 1 == R) {
    return 1;
  }
  long long &ret = d[L][R][c];
  if (~ret) return ret;
  ret = 0;
  if (c) {
    for (int(i) = (L + 1); (i) <= (R - 1); (i) += (1)) {
      if (a[L][i]) {
        ret = (ret + go(L, i, 1) * go(i, R, 1)) % MOD;
      }
    }
  }
  for (int(i) = (L + 1); (i) <= (R - 1); (i) += (1)) {
    if (a[i][R]) {
      ret = (ret + go(L, i, 0) * go(i, R, 1)) % MOD;
    }
  }
  return ret;
}
int main() {
  memset((d), -1, sizeof(d));
  int n;
  scanf("%d", &n);
  for (int(i) = (0); (i) <= (n - 1); (i) += (1))
    for (int(j) = (0); (j) <= (n - 1); (j) += (1)) scanf("%d", a[i] + j);
  for (int(i) = (0); (i) <= (n - 1); (i) += (1)) a[n][i] = a[i][n] = a[0][i];
  printf("%lld\n", go(0, n, 0));
}
