#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &a) {
  T w = 1;
  a = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') w = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) a = (a * 10) + (ch - '0');
  a *= w;
}
template <typename T>
inline void ckmax(T &a, T b) {
  a = a > b ? a : b;
}
template <typename T>
inline void ckmin(T &a, T b) {
  a = a < b ? a : b;
}
const long long MAX = 505;
const long long mod = 1e9 + 7;
inline long long add(long long x, long long y) {
  return (x + y) >= mod ? (x + y - mod) : (x + y);
}
inline long long Mul(long long x, long long y) {
  return (1ll * x * y) >= mod ? (1ll * x * y % mod) : (x * y);
}
inline void Add(long long &x, long long y) {
  x = (x + y) >= mod ? (x + y - mod) : (x + y);
}
long long a[MAX][MAX];
long long dp[MAX][MAX][2];
signed main() {
  long long n;
  read(n);
  for (long long i = 1; i <= n; ++i)
    for (long long j = 1; j <= n; ++j) read(a[i][j]);
  for (long long i = 1; i <= n; ++i) dp[i][i][1] = 1;
  for (long long len = 2; len <= n; ++len)
    for (long long i = 1, j = len; j <= n; i++, j++) {
      if (a[i][j])
        for (long long k = i; k < j; ++k)
          Add(dp[i][j][0], Mul(add(dp[i][k][0], dp[i][k][1]),
                               add(dp[k + 1][j][0], dp[k + 1][j][1])));
      for (long long k = i + 1; k <= j - 1; ++k)
        if (a[i][k])
          Add(dp[i][j][1], Mul(dp[i][k][0], add(dp[k][j][1], dp[k][j][0])));
    }
  printf("%lld\n", add(dp[1][n][0], dp[1][n][1]));
}
