#include <cstdio>
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std ;

char s [ 100 ] [ 100 ] ;
int n, m ;
map < int, int > M ;
vector < int > V ;
bool bio [ 100 ] ;

int main ( void ) {
    scanf ( "%d%d", &n, &m ) ;
    for ( int i = 0 ; i < n ; ++i )
        scanf ( "%s", s [ i ] ) ;
    for ( int i = 0 ; i < n ; ++i ) {
        int br = 0 ;
        for ( int j = m-1 ; j >= 0 ; --j ) {
            if ( s [ i ] [ j ]-'0'>0 && s [ i ] [ j ]-'0' < 10 ) { M [ s [ i ] [ j ]-'0' ] = br ; V.push_back ( br ) ; goto tamo ; } else ++br ;
        }
        tamo :;
    }
    sort ( V.begin (), V.end () ) ;
    for ( int i = 0 ; i < V.size () ; ++i ) {
        int sol = 0 ;
        memset ( bio, 0, sizeof ( bio ) ) ;
        for ( int j = 0 ; j < V.size () ; ++j ) {
            if ( M [ i+1 ] > V [ j ] && !bio [ V [ j ] ] ) { ++sol ; bio [ V [ j ] ] = 1 ; }
        }
        printf ( "%d\n", sol+1 ) ;
    }
    return 0 ;
}
