#include <bits/stdc++.h>
using namespace std;
int read() {
  char ch = getchar(), last = ' ';
  int ans = 0;
  while (ch > '9' || ch < '0') {
    last = ch;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    ans = ans * 10 + ch - '0';
    ch = getchar();
  }
  if (last == '-') ans = -ans;
  return ans;
}
const int p = 1000000007;
int n, f[505][505], g[505][505], h[505][505], a[505][505];
int main() {
  n = read();
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) a[i][j] = read();
  for (int i = 1; i <= n; i++) f[i][i] = 1;
  for (int i = 1; i < n; i++) {
    f[i][i + 1] = a[i][i + 1];
    h[i][i + 1] = 1;
    if (a[i][i + 1]) g[i][i + 1] = 1;
  }
  for (int len = 3; len <= n; len++)
    for (int l = 1; l <= n - len + 1; l++) {
      int r = l + len - 1;
      g[l][r] = 0;
      if (a[l][r]) {
        g[l][r] = f[l + 1][r];
        for (int i = l + 1; i < r; i++)
          g[l][r] = (g[l][r] + (long long)g[l][i] * h[i][r] % p) % p;
      }
      for (int i = l + 1; i <= r; i++)
        f[l][r] = (f[l][r] + (long long)g[l][i] * f[i][r] % p) % p;
      for (int i = l; i < r; i++)
        h[l][r] = (h[l][r] + (long long)f[l][i] * f[i + 1][r] % p) % p;
    }
  printf("%d\n", f[1][n]);
  return 0;
}
