#include <iostream>
#include <vector>
using namespace std;
int M = 1e9, len = 9;
struct BigInt{
vector<int> a;
void operator = (int k){
a.clear();
do{
a.push_back(k % M), k /= M;
}
while (k);
}
void operator += (BigInt X){
BigInt res;
for (int i=0, c = 0;i<max(a.size(), X.a.size()) or c > 0;i++){
if (i < a.size())
c += a[i];
if (i < X.a.size())
c += X.a[i];
res.a.push_back(c % M), c /= M;
}
swap(a, res.a);
}
};
BigInt Ways[105][105];
void print(BigInt X){
for (int i=X.a.size();i;i--){
string s = to_string(X.a[i-1]);
while (s.size() < len and i > 1)
s = '0' + s;
cout<<s;
}
cout<<'\n';
}
int main(){
int n;
cin>>n;
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++)
Ways[i][j] = (i + j == 2);
}
for (int i=1, a;i<=n;i++){
for (int j=1;j<=n;j++){
cin>>a;
if (a and i + a <= n)
Ways[i+a][j] += Ways[i][j];
if (a and j + a <= n)
Ways[i][j+a] += Ways[i][j];
}
}
print(Ways[n][n]);
}