#include <bits/stdc++.h>
using namespace std;
const int N = 510, p = 1e9 + 7;
int inc(int x, int y) {
  x += y;
  return x >= p ? x - p : x;
}
int mul(int x, int y) { return 1ll * x * y % p; }
int n, ok[N][N], f[N][N], g[N][N];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &ok[i][j]);
  for (int i = 1; i <= n; i++) f[i][i] = 1;
  for (int L = 1; L < n; L++)
    for (int l = 1; l + L <= n; l++) {
      int r = l + L;
      g[l][r] = f[l + 1][r];
      for (int i = l + 1; i < r; i++)
        if (ok[l][i]) {
          f[l][r] = inc(f[l][r], mul(g[l][i], f[i][r]));
          g[l][r] = inc(g[l][r], mul(g[l][i], g[i][r]));
        }
      if (ok[l][r]) f[l][r] = inc(f[l][r], g[l][r]);
    }
  printf("%d\n", f[1][n]);
  return 0;
}
