#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int MAX_N = 510;
const long long INF = 1e10;
int n, x, adjMat[MAX_N][MAX_N];
long long U[MAX_N][MAX_N], C[MAX_N][MAX_N];
long long countC(int i, int j);
long long countU(int i, int j);
long long countU(int i, int j) {
  if (U[i][j] < INF) {
    return U[i][j];
  }
  if (j == i + 1) {
    U[i][j] = adjMat[i][j];
    return U[i][j];
  }
  U[i][j] = 0;
  if (adjMat[i][j] == 1) {
    U[i][j] = countC(i, j);
  }
  for (int k = i + 1; k < j; ++k) {
    if (adjMat[i][k]) {
      U[i][j] += (countC(i, k) * countU(k, j)) % MOD;
      U[i][j] %= MOD;
    }
  }
  return U[i][j];
}
long long countC(int i, int j) {
  if (C[i][j] < INF) {
    return C[i][j];
  }
  if (j == i + 1) {
    C[i][j] = 1;
    return C[i][j];
  }
  C[i][j] = countU(i + 1, j);
  for (int k = i + 1; k < j; ++k) {
    if (adjMat[i][k]) {
      C[i][j] += (countC(i, k) * countC(k, j)) % MOD;
      C[i][j] %= MOD;
    }
  }
  return C[i][j];
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> x;
      adjMat[i][j] = x;
      C[i][j] = INF;
      U[i][j] = INF;
    }
  }
  cout << countU(0, n - 1);
  return 0;
}
