#include <bits/stdc++.h>
using namespace std;
struct cww {
  cww() {
    if (1) {
      ios::sync_with_stdio(false);
      cin.tie(0);
    }
  }
} star;
template <typename T>
inline bool chmin(T &l, T r) {
  bool a = l > r;
  if (a) l = r;
  return a;
}
template <typename T>
inline bool chmax(T &l, T r) {
  bool a = l < r;
  if (a) l = r;
  return a;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &it : v) is >> it;
  return is;
}
constexpr char ln = '\n';
constexpr int mod = 1e9 + 7;
const string ok = "Yes";
const string ng = "No";
int n;
int a[512][512];
bool vis[512][512];
long long dp[512][512];
long long pd[512][512];
void f(int l, int r) {
  if (vis[l][r]) return;
  vis[l][r] = true;
  dp[l][r] = 0;
  pd[l][r] = 0;
  if (l == r) {
    dp[l][r] = 1;
  } else {
    if (a[l][r]) {
      for (int i = (l); i < (r); i++) {
        f(l, i);
        f(i + 1, r);
        pd[l][r] += dp[l][i] * dp[i + 1][r] % mod;
      }
      pd[l][r] %= mod;
    }
    for (int i = (l); i < (r); i++) {
      f(l, i);
      f(i, r);
      dp[l][r] += dp[l][i] * pd[i][r] % mod;
    }
    dp[l][r] %= mod;
  }
}
int main() {
  cin >> n;
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (n); j++) cin >> a[i][j];
  for (int i = (0); i < (n + 10); i++)
    for (int j = (0); j < (n + 10); j++) vis[i][j] = false;
  f(0, n - 1);
  cout << dp[0][n - 1] << endl;
  return 0;
}
