#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, M = 10, mod = 1e9 + 7;
int n, m, x, y, msta, sta, id[(1 << M) + 5], a[N][M];
bool check(int mid) {
  for (int i = 0; i < msta; i++) id[i] = 0;
  for (int i = 1; i <= n; i++) {
    sta = 0;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] >= mid) sta |= 1 << j - 1;
    }
    id[sta] = i;
  }
  for (int i = 0; i < msta; i++) {
    for (int j = 0; j < msta; j++) {
      if ((i | j) == msta - 1 && id[i] && id[j]) {
        x = id[i], y = id[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]);
  msta = 1 << m;
  int l = 0, r = 1e9, mid;
  while (l <= r) {
    mid = l + r >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d %d\n", x, y);
  return 0;
}
