#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int sum=0,input,n,k,l,x=0,x1=0;
    cin >> n >> k;
    vector<int> matrica;
    for(int i=0;i<n*n;i++){
        cin >> input;
        matrica.push_back(input);
    }
    int resenje[k];
    for (int i=0;i<=k;i++){
        resenje[i]=-1;
    }
    int i=0;
    while (i<n*n){
        if (matrica[i]==0){i++;}
        else{
        for (int j=1;matrica[i]==matrica[i+j*n];j++){
            x=x+1;
            matrica[i+j*n]=0;
        }
        while (matrica[i]==matrica[i+1]){
            i++;
            for (int j=1;matrica[i]==matrica[i+j*n];j++){
                x1=x1+1;
                matrica[i+j*n]=0;
            }
            if (x!=x1){
                resenje[matrica[i]]=0;
            }
        }
        if (resenje[matrica[i]]==-1){resenje[matrica[i]]=1;}
        else {resenje[matrica[i]]=0;}
        x=0;x1=0;
        i++;
    }
    }
    for(int i = 0; i<=k; i++){
        if (resenje[i]==1){
            sum++;
        }
        cout << resenje[i] << endl;
    }
    //cout << sum;
    return 0;
}