#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <string>
#include <string.h>
using namespace std;

vector<string> subs;



int main()
{
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;

	vector<vector<int>> incr = vector<vector<int>>(n, vector<int>());
	map<int, map<int, int>> incr1; 
	vector<int> hasBeen = vector<int>(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) {

			int ct = 0;
			for (int j = 0; j < incr[it->first].size(); j++) {
				if (incr[it->first][j] < i) {
					ct++;
				}
				else {
					break;
				}

			}
			int sz = incr[it->first].size() - ct;

			if (sz < 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;
}