#include #define pb push_back #define mp make_pair #define mt make_tuple #define ll long long #define pii pair #define tii tuple #define N 100005 #define mod 2000003 #define X first #define Y second #define eps 0.0000000001 #define all(x) x.begin(),x.end() #define tot(x) x+1,x+n+1 using namespace std; int n, m, k, a[550][555], i, j; string name[555], sol[555]; int main() { cin.sync_with_stdio(0); cout.sync_with_stdio(0); cin >> n >> k; for(i = 1; i <= k; i++) { sol[i] = "none"; } for(i = 1; i <= n; i++) { cin >> name[i]; for(j = 1; j <= k; j++) cin >> a[i][j]; } srand(time(0)); for(i = 1; i <= n; i++) for(j = 1; j <= k - 2; j++) if(a[i][j] < a[i][j + 1] && a[i][j] < a[i][j + 2]) { if(sol[j + 2] == "none" && (rand() % 2)) { sol[j + 2] = name[i]; break; } } for(i = 1; i <= k; i++) { cout << sol[i] << '\n'; } return 0; }