#include <iostream>
typedef long long lll;
using namespace std;

int main() {
    
    int k,i,j,n,r,s,x,a[10],b[10];
    char c;
    
    
    
    cin >> r >> s;
    
    for (i=1; i<=r; i++) 
        for (j=1; j<=s; j++) {
            cin >> c;
            if ((c!='.') && (c!='S') && (c!='F')) {
               x=int(c)-int('0'); //cout << x << endl;
               a[x]=j;
               
            }}
    
    k=1; n=0;
    for (i=s; i>=1; i--) {
        for (j=1; j<=9; j++)
            if (a[j]==i) {n++; b[j]=k;}
        if (n>0) k++;
        n=0;
    }
    
    for (i=1; i<=9; i++)
        cout << b[i] << endl;

    //system ("pause");
    return 0;
}
