#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("section-anchors")
#pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
#pragma GCC optimize("vpt")
#pragma GCC optimize("rename-registers")
#pragma GCC optimize("move-loop-invariants")
#pragma GCC optimize("unswitch-loops")
#pragma GCC optimize("function-sections")
#pragma GCC optimize("data-sections")
#pragma GCC optimize("branch-target-load-optimize")
#pragma GCC optimize("branch-target-load-optimize2")
#pragma GCC optimize("btr-bb-exclusive")
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <cassert>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
#define endl '\n'
#define all(x) x.begin(), x.end()
//#define int long long
#define mk(a, b) make_pair(a, b)
     
using namespace std;
      
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<ll, ll, ll> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;
      
const ll INF = 1e9 + 228;
const ll INFLL = 1e18;
const ll MOD = 1e9 + 7;
//static const int maxn = 1e6 + 228;
const ld eps = 1e-5;
const ld eps2 = 1e-9;
const ll MOD2 = 998244353;
const ll dosz = 5e5;
const ll SZ = (1<<18);
const ld PI = atan2l(0, -1);
     
void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen("log.in", "r", stdin);
//    freopen("log.out", "w", stdout);
}

const int maxn = 1501;
int a[maxn][maxn];
vpii col[maxn][maxn];
int was[maxn * maxn + 228];
int timer = 0;
vpii nw;

inline vpii merge(vpii a, vpii &b){
    nw.clear();
    timer++;
    nw.resize(a.size() + b.size());
    merge(all(a), all(b), nw.begin());
    vpii nice;
    for(pii i:nw){
        if(was[i.second] == timer){
            continue;
        }
        nice.pb(i);
        was[i.second] = timer;
    }
    while(nice.size() > 11)
        nice.pop_back();
    return nice;
}

struct sq{
    stack<pair<vpii, vpii>> a, b;
    sq(){};
    void push(vpii nw){
        if(a.empty()){
            a.push(make_pair(nw, nw));
        } else{
            a.push(make_pair(merge(nw, a.top().first), nw));
        }
    }
    void pop(){
        if(b.empty()){
            while(!a.empty()){
                if(b.empty()){
                    b.push(make_pair(a.top().second, a.top().second));
                } else{
                    b.push(make_pair(merge(a.top().second, b.top().first), a.top().second));
                }
                a.pop();
            }
            b.pop();
        } else{
            b.pop();
        }
    }
    vpii get(){
        vpii kek;
        if(a.empty() && b.empty())
            return kek;
        if(a.empty()){
            return b.top().first;
        }
        if(b.empty()){
            return a.top().first;
        }
        return merge(a.top().first, b.top().first);
    }
    void clear(){
        while(a.size() + b.size())
            pop();
    }
};

void solve(){
    int n, q;
    cin >> n >> q;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cin >> a[i][j];
        }
    }
    int i, j;
    vpii cur, nw;
    int pnt;
    int l;
    for(int j=0; j<n; ++j){
        cur.clear();
        for(int i=n-1; i>=0; --i){
            col[i][j].reserve(11);
            nw.clear();
            nw.pb(make_pair(i, a[i][j]));
            for(pii ll:cur)
                if(ll.second != a[i][j])
                    nw.pb(ll);
            cur = nw;
            if(cur.size() > q + 1)
                cur.pop_back();
            for(l=0; l<11; l++){
                col[i][j].pb(make_pair(INF, 0));
            }
            pnt = 0;
            for(pii l:cur){
                col[i][j][pnt++] = l;
            }
        }
    }
    vi ans(n+1, 0);
    sq kek;
    int curr;
    for(i=0; i<n; ++i){
        curr = 0;
        vpii lol;
        lol = kek.get();
        kek.clear();
        for(j=0; j<n; ++j){
            while(i + curr < n && j + curr < n && (lol.size() <= q || lol[q].first > curr + i)){
                kek.push(col[i][j+curr]);
                lol = kek.get();
                ++curr;
            }
            if((lol.size() <= q || lol[q].first > curr-1 + i)){
                ++ans[curr];
            } else{
                ++ans[curr-1];
            }
            --curr;
            kek.pop();
            lol = kek.get();
        }
    }
    for(int i=n-1; i>=1; i--)
        ans[i] += ans[i+1];
    for(int i=1; i<=n; i++)
        cout << ans[i] << endl;
}

signed main(){
    fast_io();
    srand(time(NULL));
//    cout << fixed << setprecision(12);
    int q = 1;
//    cin >> q;
    while(q--)
        solve();
     
}
