#include <bits/stdc++.h>
using namespace std;
long long a[300009][9], k, i, n, m, ct, t;
pair<long long, long long> f(long long x) {
  k = 0;
  long long q[600] = {};
  vector<long long> b;
  while (k < n) {
    i = m - 1;
    ct = 0;
    t = 1;
    while (i > -1) {
      if (a[k][i] >= x) ct += t;
      t *= 2;
      i--;
    }
    if (q[ct] == 0) {
      q[ct] = k + 1;
      b.push_back(ct);
    }
    k++;
  }
  t--;
  i = 0;
  while (i < b.size()) {
    k = i;
    while (k < b.size()) {
      if ((b[i] | b[k]) == t) {
        return {q[b[i]], q[b[k]]};
      }
      k++;
    }
    i++;
  }
  return {-1, -1};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long i = 0, j;
  cin >> n >> m;
  while (i < n) {
    j = 0;
    while (j < m) {
      cin >> a[i][j];
      j++;
    }
    i++;
  }
  pair<long long, long long> w;
  long long s = 0, e = 1e10, mid, ans, an;
  while (s <= e) {
    mid = (s + e) / 2;
    w = f(mid);
    if (w.first != -1) {
      ans = w.first;
      an = w.second;
      s = mid + 1;
    } else
      e = mid - 1;
  }
  cout << ans << " " << an << "\n";
}
