#include <bits/stdc++.h>
using namespace std;
int N;
bool a[505][505];
long long memo[505][505], memo1[505][505];
long long dfs(int l, int r);
long long dfs1(int l, int r);
long long dfs(int l, int r) {
  if (l == r) return memo[l][r] = 1;
  if (memo[l][r] != -1) return memo[l][r];
  long long ans = 0;
  for (int j = l + 1; j <= r; j++) {
    ans = (ans + dfs1(l, j) * dfs(j, r) % int(1e9 + 7)) % int(1e9 + 7);
  }
  return memo[l][r] = ans;
}
long long dfs1(int l, int r) {
  if (!a[l][r]) return memo1[l][r] = 0;
  if (l == r) return memo1[l][r] = 1;
  if (memo1[l][r] != -1) return memo1[l][r];
  long long ans = 0;
  for (int j = l; j <= r - 1; j++) {
    ans = (ans + dfs(l, j) * dfs(j + 1, r) % int(1e9 + 7)) % int(1e9 + 7);
  }
  return memo1[l][r] = ans;
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    for (int j = 1; j <= N; j++) cin >> a[i][j];
  }
  memset(memo, -1, sizeof(memo));
  memset(memo1, -1, sizeof(memo1));
  cout << dfs(1, N) << endl;
  return 0;
}
