#include <bits/stdc++.h>
using namespace std;
int n;
int twod2oned(int x, int y, int type) { return type * n * n + x * n + y; }
struct edge {
  int to, length;
};
int dijkstra(const vector<vector<edge>> &graph, int source, int target) {
  vector<int> min_distance(graph.size(), INT_MAX);
  min_distance[source] = 0;
  set<pair<int, int>> active_vertices;
  active_vertices.insert({0, source});
  while (!active_vertices.empty()) {
    int where = active_vertices.begin()->second;
    if (where == target) return min_distance[where];
    active_vertices.erase(active_vertices.begin());
    for (auto ed : graph[where])
      if (min_distance[ed.to] > min_distance[where] + ed.length) {
        active_vertices.erase({min_distance[ed.to], ed.to});
        min_distance[ed.to] = min_distance[where] + ed.length;
        active_vertices.insert({min_distance[ed.to], ed.to});
      }
  }
  return 1e9;
}
int bfs(vector<vector<int>> &g, int start, int end) {
  int n = g.size();
  vector<int> dist(n, 2e9);
  dist[start] = 0;
  queue<int> q;
  q.push(start);
  while (!q.empty()) {
    int v = q.front();
    if (v == end) {
      return dist[v];
    }
    q.pop();
    for (int u : g[v]) {
      if (dist[u] > 2e8) {
        dist[u] = dist[v] + 1;
        q.push(u);
      }
    }
  }
  return 1e9;
}
int main() {
  scanf("%d", &n);
  vector<vector<int>> a(n, vector<int>(n));
  vector<pair<int, int>> pos(n * n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i][j]);
      pos[a[i][j] - 1] = {i, j};
    }
  }
  vector<vector<edge>> g(3 * n * n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int dx = -1; dx <= 1; dx += 2) {
        for (int dy = -1; dy <= 1; dy += 2) {
          for (int factor = 1;; factor++) {
            int newi = i + factor * dx;
            int newj = j + factor * dy;
            if (newi < 0 || newj < 0 || newi >= n || newj >= n) {
              break;
            }
            g[twod2oned(i, j, 0)].push_back({twod2oned(newi, newj, 0), 1000});
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int dx = -2; dx <= 2; dx++) {
        if (dx == 0) {
          continue;
        }
        for (int dy = -2; dy <= 2; dy++) {
          if (dy == 0 || abs(dx) == abs(dy)) {
            continue;
          }
          int newi = i + dx;
          int newj = j + dy;
          if (newi < 0 || newj < 0 || newi >= n || newj >= n) {
            continue;
          }
          g[twod2oned(i, j, 1)].push_back({twod2oned(newi, newj, 1), 1000});
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int newi = 0; newi < n; newi++) {
        if (newi == i) {
          continue;
        }
        g[twod2oned(i, j, 2)].push_back({twod2oned(newi, j, 2), 1000});
      }
      for (int newj = 0; newj < n; newj++) {
        if (newj == j) {
          continue;
        }
        g[twod2oned(i, j, 2)].push_back({twod2oned(i, newj, 2), 1000});
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int type = 0; type < 3; type++) {
        for (int prev_type = 0; prev_type < 3; prev_type++) {
          if (type == prev_type) {
            continue;
          }
          g[twod2oned(i, j, type)].push_back(
              {twod2oned(i, j, prev_type), 1001});
        }
      }
    }
  }
  vector<vector<pair<int, int>>> dp(
      n * n, vector<pair<int, int>>(3, make_pair(2e9, 2e9)));
  for (int type = 0; type < 3; type++) {
    dp[0][type] = {0, 0};
  }
  for (int i = 1; i < n * n; i++) {
    for (int type = 0; type < 3; type++) {
      for (int prev_type = 0; prev_type < 3; prev_type++) {
        int dist = dijkstra(
            g, twod2oned(pos[i - 1].first, pos[i - 1].second, prev_type),
            twod2oned(pos[i].first, pos[i].second, type));
        if (dist > 2e8) {
          continue;
        }
        dp[i][type] = min(dp[i][type],
                          make_pair(dp[i - 1][prev_type].first + dist / 1000,
                                    dp[i - 1][prev_type].second + dist % 1000));
      }
    }
  }
  pair<int, int> ans = make_pair(2e9, 2e9);
  for (int type = 0; type < 3; type++) {
    ans = min(ans, dp[n * n - 1][type]);
  }
  printf("%d %d\n", ans.first, ans.second);
}
