#include #include #include #include #include #include #include using namespace std; vector subs; int main() { ios::sync_with_stdio(false); int n, k; cin >> n >> k; vector> incr = vector>(n, vector()); map> incr1; vector hasBeen = vector(n,0); for (int i = 0; i < n; i++) { string s; cin >> s; subs.push_back(s); int inc=0,ct; cin >> ct; for (int j = 0; j < k-1; j++) { int c; cin >> c; if (c > ct) { inc++; if (inc >= 2) { incr[i].push_back(j+2); incr1[j+2][i] =1; } } else { inc = 0; } ct = c; } } for (int i = 1; i <= k; i++) { int min=999999, choose=-1; for (auto it = incr1[i].begin(); it != incr1[i].end(); ++it) { if (incr[it->first].size() < min && !hasBeen[it->first]) { min = incr[it->first].size(); choose = it->first; } } if (choose == -1) { cout << "none\n"; } else { cout << subs[choose] << "\n"; hasBeen[choose] = 1; } } return 0; }