#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 10;
int t, n, m, k, l, r, op, x, y;
int f[N][N];
void solve() {
cin >> n >> m;
for (int i = 1; i <= n; i++) {
cin >> x;
k = 0;
while (x) {
f[++k][x % 10]++;
x /= 10;
}
}
for (int i = 1; i <= m; i++) {
cout << max_element(f[i], f[i] + 10) - f[i] << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
solve();
return 0;
}