#include <bits/stdc++.h>
using namespace std;
using namespace std;
int a[300005][10];
int b[300005];
int n, m, x, y;
int check(int mid) {
  int c[1024] = {0};
  for (int i = 1; i <= n; i++) {
    int t = 0;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] >= mid) {
        t += (1 << (j - 1));
      }
    }
    c[t] = i;
  }
  for (int i = 0; i < (1 << m); i++) {
    for (int j = 0; j < (1 << m); j++) {
      if (c[i] && c[j] && (i | j) == (1 << m) - 1) {
        x = c[i], y = c[j];
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  int ansx, ansy;
  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) / 2;
    if (check(mid)) {
      L = mid + 1;
      ansx = x, ansy = y;
    } else {
      R = mid - 1;
    }
  }
  printf("%d %d\n", ansx, ansy);
  return 0;
}
