#include <bits/stdc++.h>
using namespace std;
const int MAXN = 505;
const int MOD = 1e9 + 7;
int n;
bool a[MAXN][MAXN];
long long dp[MAXN][MAXN][2];
int Read() {
  int x = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x * 10) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
void Put1(int x) {
  if (x > 9) Put1(x / 10);
  putchar(x % 10 ^ 48);
}
void Put(int x, char c = -1) {
  if (x < 0) putchar('-'), x = -x;
  Put1(x);
  if (c >= 0) putchar(c);
}
template <typename T>
T Max(T x, T y) {
  return x > y ? x : y;
}
template <typename T>
T Min(T x, T y) {
  return x < y ? x : y;
}
template <typename T>
T Abs(T x) {
  return x < 0 ? -x : x;
}
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) dp[i][i][0] = 1;
  for (int len = 2; len <= n; ++len)
    for (int l = 1; l + len - 1 <= n; ++l) {
      int r = l + len - 1;
      for (int i = l; i < r; ++i) {
        if (a[l][r])
          dp[l][r][0] =
              (dp[l][r][0] + (dp[l][i][0] + dp[l][i][1]) *
                                 (dp[i + 1][r][0] + dp[i + 1][r][1])) %
              MOD;
        if (a[l][i])
          dp[l][r][1] =
              (dp[l][r][1] + dp[l][i][0] * (dp[i][r][0] + dp[i][r][1])) % MOD;
      }
    }
  Put((dp[1][n][0] + dp[1][n][1]) % MOD);
  return 0;
}
