#include <bits/stdc++.h>
using namespace std;
long long data[505][505][5], adm[505][505];
long long dp(long long first, long long second, bool b) {
  if (data[first][second][b] != -1) {
    return data[first][second][b];
  }
  long long i;
  data[first][second][b] = 0;
  for (i = first + b; i < second; i++) {
    if (adm[second][i]) {
      data[first][second][b] +=
          (dp(first, i, b) * dp(i, second, 1)) % 1000000007;
      data[first][second][b] %= 1000000007;
    }
  }
  for (i = first + b; b && i < second; i++) {
    if (adm[first][i]) {
      data[first][second][b] += dp(first, i, b) * dp(i, second - 1, 0);
      data[first][second][b] %= 1000000007;
    }
  }
  return data[first][second][b];
}
int main() {
  long long t, i, j, n, m, res = 0;
  memset(data, -1, sizeof data);
  scanf("%lld", &n);
  for (i = 1; i <= n; i++) {
    data[i][i][0] = data[i][i][1] = 1;
    for (j = 1; j <= n; j++) {
      scanf("%lld", &adm[i][j]);
    }
    if (adm[i][i + 1]) {
      data[i][i + 1][0] = 1;
    } else {
      data[i][i + 1][0] = 0;
    }
    data[i][i + 1][1] = 1;
  }
  printf("%lld\n", dp(1, n, 0));
  return 0;
}
