#include <bits/stdc++.h>
namespace OI {
template <class T>
void rd(T &x) {
  x = 0;
  int f = 1;
  char c;
  while (!isdigit(c = getchar()))
    if (c == '-') f = -1;
  do {
    x = (x << 3) + (x << 1) + (c ^ 48);
  } while (isdigit(c = getchar()));
  x *= f;
}
template <class T>
void pt(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) pt(x / 10);
  putchar(x % 10 ^ 48);
}
}  // namespace OI
using namespace OI;
using namespace std;
const int N = 505, mod = 1e9 + 7;
bool a[N][N];
int n;
long long dp[N][N][2];
int main() {
  rd(n);
  for (int i = 1; i <= n; i++) {
    dp[i][i][0] = 1;
    for (int j = 1; j <= n; j++) rd(a[i][j]);
  }
  for (int l = 2; l <= n; l++)
    for (int i = 1, j = l; j <= n; i++, j++) {
      if (a[i][j])
        for (int k = i; k < j; k++)
          dp[i][j][0] =
              (dp[i][j][0] + (dp[i][k][0] + dp[i][k][1]) *
                                 (dp[k + 1][j][0] + dp[k + 1][j][1]) % mod) %
              mod;
      for (int k = i + 1; k < j; k++)
        if (a[i][k])
          dp[i][j][1] =
              (dp[i][j][1] + dp[i][k][0] * (dp[k][j][0] + dp[k][j][1]) % mod) %
              mod;
    }
  pt((dp[1][n][0] + dp[1][n][1]) % mod);
  return 0;
}
