#include <fstream>
#include <vector>

using namespace std;

const int MAXN = 100;
const int MAXL = 25;

char name[1 + MAXN][1 + MAXL];
int value[1 + MAXN][1 + MAXN];
vector<int> g[1 + MAXN];
int leftPair[1 + MAXN], rightPair[1 + MAXN];
bool seen[1 + MAXN];

bool Match(int node) {
    seen[node] = true;
    for (int i = 0; i < g[node].size(); i++)
        if (!leftPair[g[node][i]]) {
            rightPair[node] = g[node][i];
            leftPair[g[node][i]] = node;
            return true;
        }
    for (int i = 0; i < g[node].size(); i++)
        if (!seen[leftPair[g[node][i]]] && Match(leftPair[g[node][i]])) {
            leftPair[g[node][i]] = node;
            rightPair[node] = g[node][i];
            return true;
        }
    return false;
}

int main() {
    //freopen("c.in", "r", stdin);
    //freopen("c.out", "w", stdout);
    int n, k;
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) {
        scanf("%s", name[i] + 1);
        for (int j = 1; j <= k; j++) {
            scanf("%d", &value[i][j]);
            if (j >= 3 && value[i][j] > value[i][j - 1] && value[i][j - 1] > value[i][j - 2])
                g[i].push_back(j);
        }
    }
    bool ok = true;
    while (ok) {
        ok = false;
        for (int i = 1; i <= n; i++)
            seen[i] = false;
        for (int i = 1; i <= n; i++)
            if (!rightPair[i] && Match(i))
                ok = true;
    }
    for (int i = 1; i <= k; i++)
        if (!leftPair[i])
            printf("none\n");
        else
            printf("%s\n", name[leftPair[i]] + 1);
    return 0;
}