#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long f[505][505][3], n;
bool a[505][505];
long long qwq(long long l, long long r, long long num) {
  if (f[l][r][num] != -1) return f[l][r][num];
  if (l == r && num == 1) return 1;
  if (l == r && num == 2) return 0;
  f[l][r][num] = 0;
  if (num == 2) {
    for (int i = l + 1; i < r; i++) {
      f[l][r][2] += qwq(l, i - 1, 1) * qwq(i, r, 1) % mod;
      f[l][r][2] %= mod;
    }
    return f[l][r][2];
  }
  for (int i = l + 1; i <= r; i++) {
    if (!a[l][i]) continue;
    f[l][r][1] += (qwq(l, i - 1, 1) + qwq(l, i, 2)) * qwq(i, r, 1) % mod;
    f[l][r][1] %= mod;
  }
  return f[l][r][1];
}
int main() {
  memset(f, -1, sizeof(f));
  scanf("%lld", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  }
  printf("%lld\n", qwq(1, n, 1));
  return 0;
}
