#include <bits/stdc++.h>
using namespace std;
const long long inf = INT_MAX, df = 505, mod = 1e9 + 7;
long long i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, dp[df][df][2],
    a[df][df];
inline long long read() {
  long long x = 0, y = 1;
  char ch = getchar();
  while (ch > '9' || ch < '0') y = (ch == '-') ? -1 : 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return x * y;
}
int main() {
  n = read();
  for (long long i = (1); i <= (n); ++i)
    for (long long j = (1); j <= (n); ++j) a[i][j] = read();
  for (long long i = (1); i <= (n); ++i) dp[i][i][0] = 1;
  for (long long i = (2); i <= (n); ++i) {
    for (long long l = (1); l <= (n - i + 1); ++l) {
      long long r = l + i - 1;
      if (a[l][r])
        for (long long k = (l); k <= (r - 1); ++k)
          (dp[l][r][0] += (dp[l][k][0] + dp[l][k][1]) *
                          (dp[k + 1][r][0] + dp[k + 1][r][1]) % mod) %= mod;
      for (long long k = (l + 1); k <= (r - 1); ++k) {
        if (a[l][k])
          (dp[l][r][1] += dp[l][k][0] * (dp[k][r][0] + dp[k][r][1]) % mod) %=
              mod;
      }
    }
  }
  return printf("%lld\n", (dp[1][n][1] + dp[1][n][0]) % mod), 0;
}
