#include <bits/stdc++.h>
using namespace std;
int a[510][510], dp[510][510][2];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) scanf("%d", &a[i][j]);
  for (int i = 1; i <= n; i++) dp[i][i][0] = 1, dp[i][i][1] = 0;
  for (int len = 1; len < n; len++) {
    for (int i = 1; i <= n - len; i++) {
      int j = i + len;
      for (int k = i; k < j; k++) {
        if (!a[i][k]) continue;
        dp[i][j][0] =
            (dp[i][j][0] + 1LL * dp[i][k][1] * dp[k][j][0] % 1000000007) %
            1000000007;
        dp[i][j][1] =
            (dp[i][j][1] + 1LL * dp[i][k][1] * dp[k][j][1] % 1000000007) %
            1000000007;
      }
      dp[i][j][1] = (dp[i][j][1] + dp[i + 1][j][0]) % 1000000007;
      if (a[i][j]) dp[i][j][0] = (dp[i][j][0] + dp[i][j][1]) % 1000000007;
    }
  }
  cout << (dp[1][n][0] + 1000000007) % 1000000007 << endl;
  return 0;
}
