#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
const int maxn = 500 + 5;
int n;
int a[maxn][maxn];
int dp[maxn][maxn];
int dp2[maxn][maxn];
int calc2(int l, int r);
int calc(int l, int r) {
  if (l >= r) return 1;
  int& res = dp[l][r];
  if (~res) return res;
  res = 0;
  for (int i = (l + 1); i < (r); i++) {
    int sum = 0;
    if (a[l][i]) {
      addmod(res, mult(calc2(l, i), calc(i, r)));
    }
  }
  if (a[l][r]) {
    addmod(res, calc2(l, r));
  }
  return res;
}
int calc2(int l, int r) {
  int& res = dp2[l][r];
  if (~res) return res;
  res = 0;
  for (int i = (l); i < (r); i++) {
    addmod(res, mult(calc(l, i), calc(i + 1, r)));
  }
  return res;
}
void solve() {
  cin >> n;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n); j++) cin >> a[i][j];
  memset(dp, -1, sizeof(dp)), memset(dp2, -1, sizeof(dp2));
  cout << calc(0, n - 1) << "\n";
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0), cin.tie(0);
  solve();
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
