#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std ;

/*ifstream cin ("input") ;
ofstream cout ("output") ;*/

int main(int argc, char const *argv[])
{
	srand(time(NULL)) ;
	int n, k ;
	cin >> n >> k ;
	vector <string> v (n + 1) ; 
	vector <int> c (k + 1) ; 
	vector <int> *where = new vector <int> [n + 1] ;
	vector <int> ap (n + 1, 0) ; 
	vector <int> sol (k + 1) ;
	vector <int> *who = new vector <int> [k + 1] ; 
	for (int i = 1 ; i <= n ; ++ i) {
		cin >> v [i] ; 
		for (int j = 1 ; j <= k ; ++ j) {
			cin >> c [j] ; 
			if (j - 2 >= 1 and c [j] > c [j - 1] and c [j - 1] > c [j - 2]) {
				where [i].push_back (j) ;
				ap [i] = 1 ;  
				who [j].push_back (i) ;				
			}
		}
	}
	for (int i = 1 ; i <= k ; ++ i) {
		random_shuffle (who[i].begin(), who[i].end()) ;
		while (who[i].size() and ap [who[i].back()] == -1) {
			who[i].pop_back() ; 
		}
		if (who[i].size()) {
			cout << v[who [i].back()] << '\n' ;
			ap [who [i].back()] = -1 ; 
		}
		else {
			cout << "none\n" ;
		}
	}
	return 0;
}