#include <bits/stdc++.h>
// mrrrowwww meeowwwww :3
// go play vivid/stasis! !! !!! https://vividstasis.gay
#define fo(i, a, b) for (auto i = (a); i < (b); i++)
#define of(i, a, b) for (auto i = (b); i-- > (a);)
#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define be(a) a.begin(), a.end()
using namespace std;
int ____init = []{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
return 0;
}();
int jump[100][100];
__int128_t dp[100][100];
int main() {
int n; cin >> n;
fo(i, 0, n) fo(j, 0, n) cin >> jump[i][j];
dp[0][0] = 1;
fo(i, 0, n) fo(j, 0, n) {
if (jump[i][j] <= 0) continue;
if (i + jump[i][j] < n) dp[i + jump[i][j]][j] += dp[i][j];
if (j + jump[i][j] < n) dp[i][j + jump[i][j]] += dp[i][j];
}
vector<int> res;
while (dp[n - 1][n - 1] > 0) res.pb(dp[n - 1][n - 1] % 10), dp[n - 1][n - 1] /= 10;
of(i, 0, res.size()) cout << res[i];
}