#include <bits/stdc++.h>
using namespace std;
const long long N = 510;
const long long Mod = 1e9 + 7;
long long Dp_Connected[N][N];
long long Dp_NotAsked[N][N];
long long n, mapp[N][N];
void Read() {
  scanf("%lld", &n);
  for (long long i = 1; i <= n; i++)
    for (long long j = 1; j <= n; j++) scanf("%lld", &mapp[i][j]);
  for (long long i = 1; i <= n; i++) Dp_Connected[i][i] = Dp_NotAsked[i][i] = 1;
}
void Solve() {
  for (long long RNG = 1; RNG < n; RNG++) {
    for (long long FPX = 1; FPX <= n - RNG; FPX++) {
      if (mapp[FPX][FPX + RNG])
        for (long long IG = FPX; IG < FPX + RNG; IG++)
          Dp_Connected[FPX][FPX + RNG] =
              (Dp_Connected[FPX][FPX + RNG] +
               Dp_NotAsked[FPX][IG] * Dp_NotAsked[IG + 1][FPX + RNG] % Mod) %
              Mod;
      for (long long IG = FPX; IG <= FPX + RNG; IG++)
        Dp_NotAsked[FPX][FPX + RNG] =
            (Dp_NotAsked[FPX][FPX + RNG] +
             Dp_Connected[FPX][IG] * Dp_NotAsked[IG][FPX + RNG] % Mod) %
            Mod;
    }
  }
}
void Write() { printf("%lld\n", (Dp_NotAsked[1][n] + Mod) % Mod); }
int main() {
  Read();
  Solve();
  Write();
  return 0;
}
