#include<bits/stdc++.h>

using namespace std;
const int N = 1505;
int A[N * N], ans[N], n, q;
bool v[N * N];
vector<int> R[2], D[2][N], RD[2][N], V;
#define  f(x, y, v) max({v / n - x + 1, v % n - y + 1})

inline void merge(int x, int y, const vector<int> &a, const vector<int> &b, vector<int> &c) {
    int i = 0, j = 0;
    c.clear();
    while ((int) c.size() <= q && (i < (int) a.size() || j < (int) b.size())) {
        if (i < a.size() && (j == (int) b.size() || f(x, y, a[i]) < f(x, y, b[j]))) {
            if (!v[A[a[i]]])v[A[a[i]]] = true, c.push_back(a[i]);
            i++;
        } else {
            if (!v[A[b[j]]])v[A[b[j]]] = true, c.push_back(b[j]);
            j++;
        }
    }
    for (int x:c)v[A[x]] = false;
}

int main() {
    scanf("%d%d", &n, &q);
    for (int i = 0; i < n * n; i++)
        scanf("%d", &A[i]);
    for (int i = n - 1; ~i; i--) {
        R[n - 1 & 1].clear();
        for (int j = n - 1; ~j; j--) {
            merge(i, j, RD[i + 1 & 1][j + 1], {i * n + j}, RD[i & 1][j]);
            merge(i, j, D[i + 1 & 1][j], RD[i & 1][j], D[i & 1][j]);
            if (j != n - 1)merge(i, j, R[j + 1 & 1], RD[i & 1][j + 1], R[j & 1]);
            merge(i, j, R[j & 1], D[i & 1][j], V);
            ans[min({n - i, n - j, (int) V.size() > q ? f(i, j, V.back()) - 1 : n})]++;
        }
    }
    for (int i = n - 1; i >= 1; i--)ans[i] += ans[i + 1];
    for (int i = 1; i <= n; i++)printf("%d\n", ans[i]);
    return 0;
}