#include <bits/stdc++.h>
using namespace std;
const int N = 510;
const long long mod = 1e9 + 7;
bool A[N][N];
int n;
long long f[N][N][2];
int main() {
  std::cin.tie(0);
  std::cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> A[i][j];
  for (int i = 1; i <= n; i++) f[i][i][1] = 1;
  for (int len = 2; len <= n; len++) {
    for (int l = 1; l + len - 1 <= n; l++) {
      int r = l + len - 1;
      if (A[l][r])
        for (int k = l; k < r; k++)
          f[l][r][0] =
              (f[l][r][0] + (f[l][k][0] + f[l][k][1]) % mod *
                                ((f[k + 1][r][0] + f[k + 1][r][1]) % mod)) %
              mod;
      for (int k = l + 1; k < r; k++)
        if (A[l][k])
          f[l][r][1] =
              (f[l][r][1] + f[l][k][0] * ((f[k][r][0] + f[k][r][1]) % mod)) %
              mod;
    }
  }
  cout << (f[1][n][0] + f[1][n][1]) % mod;
}
