#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
int n, m;
int bitmask;
int a[300100][10];
int id1, id2;
bool ok(int val) {
  vector<int> d[300];
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    for (int j = 1; j <= m; j++)
      if (a[i][j] >= val) tmp += (1 << (j - 1));
    d[tmp].push_back(i);
  }
  for (int i = 0; i < (1 << m); i++)
    for (int j = 0; j < (1 << m); j++)
      if ((i | j) == bitmask) {
        if (d[i].size() > 0 && d[j].size() > 0) {
          id1 = d[i][0];
          id2 = d[j][0];
          return true;
        }
      }
  return false;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  bitmask = (1 << m) - 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  int lo, hi, mid, res;
  lo = 0;
  hi = INF;
  while (lo <= hi) {
    mid = (lo + hi) >> 1;
    if (ok(mid)) {
      res = mid;
      lo = mid + 1;
    } else
      hi = mid - 1;
  }
  cout << id1 << " " << id2;
  return 0;
}
