#include using namespace std; int lol[500][500]; string name[500]; struct BipartiteMatcher { vector> G; vector L, R, Viz; BipartiteMatcher(int n, int m) : G(n), L(n, -1), R(m, -1), Viz(n) {} void AddEdge(int a, int b) { G[a].push_back(b); } bool Match(int node) { if(Viz[node]) return false; Viz[node] = true; for(auto vec : G[node]) { if(R[vec] == -1 || Match(R[vec])) { L[node] = vec; R[vec] = node; return true; } } return false; } int Solve() { bool ok = true; while(ok) { ok = false; fill(Viz.begin(), Viz.end(), 0); for(int i = 0; i < L.size(); ++i) if(L[i] == -1) ok |= Match(i); } int ret = 0; for(int i = 0; i < L.size(); ++i) ret += (L[i] != -1); return ret; } }; int main() { int n, k; cin >> n >> k; BipartiteMatcher matcher(k, n); for(int i = 0; i < n; ++i) { cin >> name[i]; for(int j = 0; j < k; ++j) { cin >> lol[i][j]; if(j >= 2 && lol[i][j - 2] < lol[i][j - 1] && lol[i][j - 1] < lol[i][j]) matcher.AddEdge(j, i); } } matcher.Solve(); for(int i = 0; i < k; ++i) { if(matcher.L[i] == -1) cout << "none\n"; else cout << name[matcher.L[i]] << endl; } return 0; }