#include <bits/stdc++.h>
using namespace std;
int n, a[550][550];
long long f[550][550], g[550][550];
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] = 1;
  for (int l = 1; l < n; l++)
    for (int i = 1; i + l <= n; i++) {
      int j = i + l;
      for (int k = i; k <= j; k++) {
        if (k < j && a[i][j])
          f[i][j] = (f[i][j] + (f[i][k] + g[i][k]) % 1000000007 *
                                   (f[k + 1][j] + g[k + 1][j]) % 1000000007) %
                    1000000007;
        if (k > i && k < j && a[j][k])
          g[i][j] = (g[i][j] +
                     (f[i][k] + g[i][k]) % 1000000007 * f[k][j] % 1000000007) %
                    1000000007;
      }
    }
  printf("%I64d\n", (f[1][n] + g[1][n]) % 1000000007);
  return 0;
}
