#include <stdio.h>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<ld, ld>
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second

const int kMaxN = 105;

int n, k;
string s[kMaxN];
int a[kMaxN][kMaxN];

class MaxMatchingBipartiteGraph {
 public:
  MaxMatchingBipartiteGraph(const int num_vertices_left,
                            const int num_vertices_right) :
    num_vertices_left_(num_vertices_left),
    num_vertices_right_(num_vertices_right) {
    edges_.resize(num_vertices_left_ + 1);
    visited_.resize(num_vertices_left_ + 1, 0);
    match_for_left_.resize(num_vertices_left_ + 1, 0);
    match_for_right_.resize(num_vertices_right_ + 1, 0);
  }

  void AddEdge(const int from, const int to) {
    edges_[from].push_back(to);
  }

  int GetMaximumMatching() {
    int matching = 0;
    bool ok = 1;
    while (ok) {
      ok = 0;
      fill(visited_.begin(), visited_.end(), 0);
      for (int i = 1; i <= num_vertices_left_; i++) {
        if (!match_for_left_[i] && PairUp(i)) {
          ok = 1;
          matching++;
        }
      }
    }
    return matching;
  }

  int GetMatchForLeft(const int vertex) const {
    return match_for_left_[vertex];
  }

  int GetMatchForRight(const int vertex) const {
    return match_for_right_[vertex];
  }

 private:
  bool PairUp(const int vertex) {
    if (visited_[vertex]) {
      return 0;
    }
    visited_[vertex] = 1;

    for (auto it : edges_[vertex])
      if (!match_for_right_[it]) {
        match_for_left_[vertex] = it;
        match_for_right_[it] = vertex;
        return 1;
      }

    for (auto it : edges_[vertex])
      if (PairUp(match_for_right_[it])) {
        match_for_left_[vertex] = it;
        match_for_right_[it] = vertex;
        return 1;
      }

    return 0;
  }

  const int num_vertices_left_;
  const int num_vertices_right_;
  vector<vector<int>> edges_;
  vector<bool> visited_;
  vector<int> match_for_left_;
  vector<int> match_for_right_;
};

int main() {
  cin.sync_with_stdio(false);

  cin >> n >> k;

  MaxMatchingBipartiteGraph mlc(n, k);

  for (int i = 1; i <= n; i++) {
    cin >> s[i];
    int cnt = 0;
    for (int j = 1; j <= k; j++) {
      cin >> a[i][j];
      if (a[i][j] > a[i][j - 1]) {
        cnt++;
      } else {
        cnt = 1;
      }

      if (cnt >= 3) {
        mlc.AddEdge(i, j);
      }
    }
  }

  mlc.GetMaximumMatching();

  for (int i = 1; i <= k; i++) {
    int reddit = mlc.GetMatchForRight(i);
    if (reddit == 0) {
      cout << "none\n";
    } else {
      cout << s[reddit] << '\n';
    }
  }

  return 0;
}