#include <bits/stdc++.h>
using namespace std;
int n, m, siz, a[300005][10];
pair<int, int> b[305];
bool v[305];
int main() {
  int mn, mx;
  cin >> n >> m;
  mn = INT_MAX;
  mx = INT_MIN;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) {
      cin >> a[i][j];
      mn = min(mn, a[i][j]);
      mx = max(mx, a[i][j]);
    }
  int l, r, mid;
  pair<int, int> ans;
  l = mn;
  r = mx;
  while (l <= r) {
    mid = (l + r) / 2;
    for (int i = 1; i <= n; ++i) {
      int state = 0;
      for (int j = 1; j <= m; ++j)
        if (a[i][j] >= mid) state += (1 << j - 1);
      if (!v[state]) b[++siz] = make_pair(state, i), v[state] = 1;
    }
    bool flag = 0;
    pair<int, int> tmp;
    for (int i = 1; i <= siz; ++i)
      for (int j = i; j <= siz; ++j)
        if ((b[i].first | b[j].first) == (1 << m) - 1) {
          flag = 1;
          tmp = make_pair(b[i].second, b[j].second);
        }
    if (flag)
      ans = tmp, l = mid + 1;
    else
      r = mid - 1;
    for (int i = 1; i <= siz; ++i) v[b[i].first] = 0;
    siz = 0;
  }
  cout << ans.first << ' ' << ans.second << endl;
  return 0;
}
