#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
int n;
vector<vector<int>> c;
vector<vector<int>> dp;
const int mazb=1e9;





void bfs(){
    for (int diag=0; diag<2*n-2; diag++){
        int i,j;
        if (diag>n-1){
            i=diag-(n-1);
            j=diag-i;
        }
        else{
            i=0;
            j=diag-i;
        }
        while (true){
            if (i==n || j==-1){
                break;
            }
            //cout << i << " " << j << " " << c[i][j] << " " << dp[i][j] << endl;
            if (i==0 && j==0){
                dp[i][j]=c[i][j];
            }
            else if (i==0){
                dp[i][j]=c[i][j]+dp[i][j-1];
            }
            else if (j==0){
                dp[i][j]=c[i][j]+dp[i-1][j];
            }
            else{
                dp[i][j]=c[i][j]+min(dp[i-1][j],dp[i][j-1]);
            }
            //cout << i << " " << j << " " << c[i][j] << " " << dp[i][j] << endl;
            i++;
            j--;
        }
    }
    cout << c[n-1][n-1]+min(dp[n-2][n-1],dp[n-1][n-2]);
}

/*
int dfs(int i,int j,int mizb){
    if (i==n-1 && j==n-1){
        return c[i][j];
    }
    if (i==n-1){
        return c[i][j]+dfs(i,j+1);
    }
    else if (j==n-1){
        return c[i][j]+dfs(i+1,j);
    }
    else{
        return c[i][j]+min(dfs(i+1,j),dfs(i,j+1));
    }
}
*/
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    c.resize(n,vector<int>(n));
    dp.resize(n,vector<int>(n,mazb));
    for (int i=0; i<n; i++){
        string s;
        cin >> s;
    }
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            cin >> c[i][j];
        }
    }
    bfs();
    return 0;
}