#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long MOD = 1000000007;
template <class T>
int getbit(T x, int pos) {
  return (x >> (pos - 1)) & 1;
}
template <class T>
void turn_on(T &x, int pos) {
  x = x | ((T)1 << (pos - 1));
}
template <class T>
void turn_off(T &x, int pos) {
  x = x & ~((T)1 << (pos - 1));
}
template <class T>
T sqr(T a) {
  return a * a;
}
int n, a[502][502], p[502];
long long f[502][502], g[502][502];
void init() {
  for (int i = 0; i < (int)n; ++i)
    for (int j = 0; j < (int)n; ++j) cin >> a[i][j];
}
void solve() {
  for (int i = 0; i < (int)n; ++i) f[i][1] = g[i][1] = 1;
  for (int len = 2; len <= n; ++len)
    for (int L = 0; L < (int)n; ++L) {
      if (a[L][(L + len - 1) % n] == 0)
        g[L][len] = 0;
      else {
        for (int len2 = 1; len2 <= len - 1; ++len2) {
          g[L][len] =
              (g[L][len] + f[L][len2] * f[(L + len2) % n][len - len2]) % MOD;
        }
      }
      for (int len2 = 2; len2 <= len; ++len2) {
        if (a[L][(L + len2 - 1) % n]) {
          f[L][len] =
              (f[L][len] + g[L][len2] * f[(L + len2 - 1) % n][len - len2 + 1]) %
              MOD;
        }
      }
    }
  cout << f[0][n];
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  init();
  solve();
}
