#include <bits/stdc++.h>   using namespace std;   const int LIM = 3e5 + 7;   int T[LIM][10], n, m, ans1, ans2;   bool spr(int x) {     vector<int> V[1 << m];     for (int i = 0; i < (n); ++i) {       int l = 0;       for (int j = 0; j < (m); ++j) {         if (T[i][j] >= x) l += 1 << j;       }       V[l].push_back(i);     }     for (int i = 0; i < (1 << m); ++i) {       if (!V[i].size()) continue;       for (int j = 0; j < (1 << m); ++j) {         if (!V[j].size()) continue;         if ((i | j) == (1 << m) - 1) {           ans1 = V[i][0];           ans2 = V[j][0];           return true;         }       }     }     return false;   }   int main() {     ios_base::sync_with_stdio(0);     cin.tie(0);     cin >> n >> m;     for (int i = 0; i < (n); ++i)       for (int j = 0; j < (m); ++j) cin >> T[i][j];     int p = 0, k = 1000000000;     while (p < k) {       int sr = (p + k) / 2;       if (spr(sr))         p = sr + 1;       else         k = sr - 1;     }     spr(p);     cout << ans1 + 1 <<     << ans2 + 1 <<   n ;   }   