#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000;
const int mod = 1e9 + 7;
int a[300010][10], sta[1029];
int o1, o2, n, m;
bool ok(int x) {
  for (int i = 0; i <= (1 << m); i++) sta[i] = 0;
  for (int i = 1; i <= n; i++) {
    int st = 0;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] >= x) {
        st = (st) | (1 << (j - 1));
      }
    }
    sta[st] = i;
  }
  int l = (1 << m) - 1;
  for (int i = 0; i <= l; i++) {
    for (int j = 0; j <= l; j++) {
      if ((i | j) == l && sta[i] && sta[j]) {
        o1 = sta[i], o2 = sta[j];
        return true;
      }
    }
  }
  return false;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  int l = 0, r = 1e9;
  while (l <= r) {
    int mid = l + r >> 1;
    if (ok(mid)) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  printf("%d %d\n", o1, o2);
}
