#include <bits/stdc++.h>
using namespace std;
int n, m;
int ansx, ansy;
int a[300005][10];
int b[300005];
int check(long long x) {
  memset(b, 0, sizeof(b));
  for (int i = 1; i <= n; i++) {
    int p = 0;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] >= x) p += (1 << (j - 1));
    }
    b[p] = i;
  }
  int k = (1 << m);
  int c = (1 << m) - 1;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (b[i] && b[j] && ((i | j) == c)) {
        ansx = b[i];
        ansy = b[j];
        return 1;
      }
    }
  }
  return 0;
}
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]);
    }
  }
  long long l = 0, r = 1e9;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid)) {
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  printf("%d %d\n", ansx, ansy);
}
