#include <iostream>
#include <string>
#include <vector>
using ll=long long;
using namespace std;

// auto mod int
//const int mod = 1000000007;
//const int mod = 998244353;
int mod;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  //mint inv() const { return pow(mod-2);}

  //supports not prime
  mint modinv(ll a) {
    long long b = mod, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= mod;
    if (u < 0) u += mod;
    mint res(u);
    return res;
}
  mint& operator/=(const mint a) { return *this *= modinv(a.x);}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(){
    int N,K;
    cin>>N>>K>>mod;

    int MX=N*(N+1)*K/2+1;

    vector<vector<mint>> dp(N+1, vector<mint> (MX));
    dp[0][0]=1;
    int s=0;
    for(int i=1;i<=N;i++){
        vector<mint> ps(i);
        s+=i;
        for(int j=0;j<=s*K;j++){
            int x=j%i;
            ps[x]+=dp[i-1][j];
            if(j-i*(K+1)>=0){
                ps[x]-=dp[i-1][j-i*(K+1)];
            }
            dp[i][j]=ps[x];
        }
    }

    s=0;

    for(int i=1;i<=N;i++){
        s+=i;
        mint ans;
        for(int t=0;t<=s*K;t++){
            ans+=dp[i-1][t]*dp[N-i][t];
        }
        ans=ans*(K+1)-1;
        cout<<ans<<endl;
    }
    
    return 0;
}
#include <bits/stdc++.h>          
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repp(i, st, en) for (ll i = (ll)st; i < (ll)(en); i++)
#define repm(i, st, en) for (ll i = (ll)st; i >= (ll)(en); i--)
#define all(v) v.begin(), v.end()
void chmax(ll &x, ll y) {x = max(x,y);}
void chmin(ll &x, ll y) {x = min(x,y);}
void Yes() {cout << "Yes" << endl; exit(0);}
void No() {cout << "No" << endl; exit(0);}
template<class in_Cout> void Cout(in_Cout x) {cout << x << endl; exit(0);}
template<class in_vec_cout>
void vec_cout(vector<in_vec_cout> vec) {
    for (in_vec_cout res : vec) {cout << res << " ";}
    cout << endl;
}

const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll maxN = 880;

ll N, K, C;
ll A[maxN][maxN], S[maxN][maxN];

bool OK(ll X) {
    for (ll i=1; i<=N; i++) {
        for (ll j=1; j<=N; j++) {
            if (A[i][j]>X) S[i][j] = 1;
            else S[i][j] = 0;
        }
    }
    for (ll i=1; i<=N; i++) {
        for (ll j=1; j<=N; j++) {
            S[i][j] += S[i][j-1];
        }
    }
    for (ll j=1; j<=N; j++) {
        for (ll i=1; i<=N; i++) {
            S[i][j] += S[i-1][j];
        }
    }
    for (ll i=K; i<=N; i++) {
        for (ll j=K; j<=N; j++) {
            ll cnt = S[i][j] - S[i-K][j] - S[i][j-K] + S[i-K][j-K];
            if (cnt<C) return true;
        }
    }
    return false;
}

int main() {
    cin >> N >> K;
    C = K*K/2 + 1;
    for (ll i=1; i<=N; i++) {
        for (ll j=1; j<=N; j++) {
            cin >> A[i][j];
        }
    }
    ll l = -inf, r = inf;
    while (r-l>1) {
        ll m = (l+r)/2;
        if (OK(m)) r = m;
        else l = m;
    }
    Cout(r);
}