#include <bits/stdc++.h>
int A[300010][10];
int ton[1000];
int N, M;
int I, J;
bool check(int);
int main() {
  int i, j, k;
  scanf("%d%d", &N, &M);
  for (i = 1; i <= N; i++)
    for (j = 1; j <= M; j++) scanf("%d", &A[i][j]);
  int L = 0, R = 1e9;
  int mid = (L + R) >> 1;
  while (R - L >= 3) {
    if (check(mid))
      L = mid;
    else
      R = mid - 1;
    mid = (L + R) >> 1;
  }
  for (mid = R; mid >= L; mid--)
    if (check(mid)) {
      printf("%d %d\n", I, J);
      return 0;
    }
}
bool check(int ans) {
  int i, j, k, l;
  memset(ton, 0, sizeof(ton));
  for (i = 1; i <= N; i++) {
    k = 0;
    l = 1;
    for (j = 1; j <= M; j++) {
      if (A[i][j] >= ans) k |= l;
      l <<= 1;
    }
    ton[k] = i;
  }
  for (i = 0; i < (1 << M); i++)
    for (j = 0; j < (1 << M); j++)
      if ((i | j) == (1 << M) - 1 && ton[i] && ton[j]) {
        I = ton[i], J = ton[j];
        return true;
      }
  return false;
}
