#include <bits/stdc++.h>
using namespace std;
const int N = 11;
struct lol {
  int x, y, nxt, cur;
  bool operator<(const lol& s) const {
    if (x != s.x) return x < s.x;
    if (y != s.y) return y < s.y;
    if (nxt != s.nxt) return nxt < s.nxt;
    return cur < s.cur;
  }
};
int Hdx[] = {1, 1, -1, -1, 2, 2, -2, -2}, Hdy[] = {2, -2, 2, -2, 1, -1, 1, -1};
int Ldx[] = {1, 1, -1, -1}, Ldy[] = {-1, 1, -1, 1};
int a[N][N];
pair<int, int> co[N * N], d[N][N][N * N][3];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      cin >> a[i][j];
      co[a[i][j]] = {i, j};
    }
  queue<pair<pair<int, int>, lol> > q;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      for (int val = 0; val <= n * n + 1; ++val)
        for (int k = 0; k < 3; ++k) d[i][j][val][k] = {1e9, 1e9};
  lol st = {co[1].first, co[1].second, 2, 0};
  d[co[1].first][co[1].second][2][0] = {0, 0};
  q.push({{0, 0}, st});
  for (int i = 1; i <= 2; ++i) {
    st.cur = i, q.push({{0, 0}, st});
    d[co[1].first][co[1].second][2][i] = {0, 0};
  }
  while (q.size()) {
    auto T = q.front();
    int dst = T.first.first, ch = T.first.second;
    lol kek = T.second;
    int x = kek.x, y = kek.y, nxt = kek.nxt, cur = kek.cur;
    pair<int, int> rel = {dst + 1, ch};
    q.pop();
    if (T.first != d[x][y][nxt][cur]) continue;
    if (nxt == n * n + 1) continue;
    if (cur == 0) {
      for (int i = 0; i < 8; ++i) {
        int nx = x + Hdx[i], ny = y + Hdy[i];
        if (nx < 0 || nx >= n) continue;
        if (ny < 0 || ny >= n) continue;
        int nnxt = (a[nx][ny] == nxt) + nxt;
        if (d[nx][ny][nnxt][cur] > rel) {
          d[nx][ny][nnxt][cur] = rel;
          q.push({rel, {nx, ny, nnxt, cur}});
        }
      }
    } else if (cur == 1) {
      for (int g = 1; g < n; ++g) {
        for (int i = 0; i < 4; ++i) {
          int nx = x + g * Ldx[i], ny = y + g * Ldy[i];
          if (nx < 0 || nx >= n) continue;
          if (ny < 0 || ny >= n) continue;
          int nnxt = (a[nx][ny] == nxt) + nxt;
          if (d[nx][ny][nnxt][cur] > rel) {
            d[nx][ny][nnxt][cur] = rel;
            q.push({rel, {nx, ny, nnxt, cur}});
          }
        }
      }
    } else {
      int nx, ny = y;
      for (int i = 0; i < n; ++i) {
        nx = i;
        int nnxt = (a[nx][ny] == nxt) + nxt;
        if (d[nx][ny][nnxt][cur] > rel) {
          d[nx][ny][nnxt][cur] = rel;
          q.push({rel, {nx, ny, nnxt, cur}});
        }
      }
      nx = x;
      for (int i = 0; i < n; ++i) {
        ny = i;
        int nnxt = (a[nx][ny] == nxt) + nxt;
        if (d[nx][ny][nnxt][cur] > rel) {
          d[nx][ny][nnxt][cur] = rel;
          q.push({rel, {nx, ny, nnxt, cur}});
        }
      }
    }
    for (int ncur = 0; ncur < 3; ++ncur) {
      if (ncur == cur) continue;
      rel = {dst + 1, ch + 1};
      if (d[x][y][nxt][ncur] > rel) {
        d[x][y][nxt][ncur] = rel;
        q.push({rel, {x, y, nxt, ncur}});
      }
    }
  }
  pair<int, int> ans = {1e9, 1e9};
  int x = co[n * n].first, y = co[n * n].second;
  for (int i = 0; i < 3; ++i) ans = min(ans, d[x][y][n * n + 1][i]);
  cout << ans.first << " " << ans.second;
}
