#include <bits/stdc++.h>
using namespace std;
inline long long Abs(long long x) {
  if (x > 0) return x;
  return -x;
}
inline long long Min(long long x, long long y) { return x < y ? x : y; }
inline long long Max(long long x, long long y) { return x > y ? x : y; }
inline void read(long long &x) {
  x = 0;
  long long f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 3) + (x << 1) + (s ^ 48);
    s = getchar();
  }
  x *= f;
}
bool Ok[505][505];
long long dp[505][505][2], n;
long long Solve(long long l, long long r, bool Type) {
  if (dp[l][r][Type] != -1) return dp[l][r][Type];
  if (l == r) return dp[l][r][Type] = 1;
  dp[l][r][Type] = 0;
  if (!Type) {
    for (register int Mid = l; Mid < r; ++Mid) {
      if (Ok[l][Mid]) {
        long long Pre = Solve(l, Mid, 1), Back = Solve(Mid, r, 0);
        if (Ok[Mid][r]) Back += Solve(Mid, r, 1);
        dp[l][r][Type] += Pre * Back, dp[l][r][Type] %= 1000000007;
      }
    }
  } else {
    for (register int Mid = l; Mid < r; ++Mid) {
      long long Pre = Solve(l, Mid, 0);
      if (Ok[l][Mid]) Pre += Solve(l, Mid, 1);
      long long Back = Solve(Mid + 1, r, 0);
      if (Ok[Mid + 1][r]) Back += Solve(Mid + 1, r, 1);
      dp[l][r][Type] += Pre * Back, dp[l][r][Type] %= 1000000007;
    }
  }
  return dp[l][r][Type];
}
int main() {
  read(n);
  for (register int i = 1; i <= n; ++i)
    for (register int j = 1; j <= n; ++j) scanf("%d", &Ok[i][j]);
  memset(dp, -1, sizeof dp);
  long long Ans = Solve(1, n, 0);
  if (Ok[1][n]) Ans += Solve(1, n, 1);
  printf("%lld", Ans % 1000000007);
  return 0;
}
