#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int n, m;
int arr[301010][8];
int ansx, ansy;
int cand[256];
int solve(long long x) {
  memset(cand, -1, sizeof(cand));
  for (int i = 0; i < n; i++) {
    int bit = 1;
    int mask = 0;
    for (int j = 0; j < m; j++) {
      if (arr[i][j] >= x) mask += bit;
      bit <<= 1;
    }
    cand[mask] = i;
  }
  for (int i = 0; i < (1 << m); i++) {
    for (int j = 0; j < (1 << m); j++) {
      if ((i | j) == (1 << m) - 1) {
        if (cand[i] != -1 && cand[j] != -1) {
          ansx = cand[i];
          ansy = cand[j];
          return 1;
        }
      }
    }
  }
  return 0;
}
long long binary_search(long long x, long long y) {
  long long lo = x - 1;
  long long hi = y + 1;
  while (lo + 1 < hi) {
    long long mid = (lo + hi) / 2;
    if (solve(mid))
      lo = mid;
    else
      hi = mid;
  }
  return lo;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) scanf("%d", &arr[i][j]);
  }
  long long ans = binary_search(0, (long long)1e9);
  solve(ans);
  printf("%d %d\n", ansx + 1, ansy + 1);
  return 0;
}
