#include <bits/stdc++.h>
using namespace std;
const int maxN = 505;
const long long modu = 1e9 + 7;
int n, a[maxN][maxN];
long long f[maxN][maxN][2];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; ++i) f[i][i][0] = 0, f[i][i][1] = 1;
  for (int len = 2; len <= n; ++len)
    for (int l = 1; l <= n - len + 1; ++l) {
      int r = l + len - 1;
      for (int k = l + 1; k <= r; ++k) {
        if (a[l][r]) (f[l][r][0] += f[l][k - 1][1] * f[k][r][1]) %= modu;
        (f[l][r][1] += f[l][k][0] * f[k][r][1]) %= modu;
      }
    }
  printf("%lld", f[1][n][1]);
}
