#include <bits/stdc++.h>
using namespace std;

#define is_valid(y, x) !visited[y][x] && x >= 0 && y >= 0 && x < n && y < n

int terrain[128][128];
int d[128][128];
int visited[128][128];
int dir[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
int n;
int pn;

void dk() {
  priority_queue<pair<int, pair<int, int>>> q;
  d[0][0] = terrain[0][0];
  q.push({-terrain[0][0], {0, 0}});

  while (!q.empty()) {
    auto c = q.top();
    q.pop();
    int dist = -c.first;
    auto loc = c.second;
    if (visited[loc.first][loc.second])
      continue;

    visited[loc.first][loc.second] = 1;
    for (int i = 0; i < 4; i++) {
      int newy = loc.first + dir[i][0];
      int newx = loc.second + dir[i][1];
      if (is_valid(newy, newx)) {
        int mindist = min(d[newy][newx],
            dist + terrain[newy][newx]);
        d[newy][newx] = mindist;
        q.push({-mindist, {newy, newx}});
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  while (cin >> n && n) {
    memset(d, 0x7f, sizeof (d));
    memset(visited, 0, sizeof (visited));
    for (int j = 0; j < n; j++) {
      for (int i = 0; i < n; i++) {
        cin >> terrain[j][i];
      }
    }
    dk();
    cout << "Problem " << ++pn << ": ";
    cout << d[n-1][n-1] << '\n';
  }
  return 0;
}