#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 3e5 + 10;
int n, m;
int a[maxn][10];
int id[maxn];
int ans1, ans2;
bool check(int mid) {
  memset(id, 0, sizeof(id));
  for (int i = 1; i <= n; i++) {
    int s = 0;
    for (int j = 0; j < m; j++) {
      if (a[i][j] >= mid) s |= (1 << j);
    }
    id[s] = i;
  }
  for (int i = (1 << m) - 1; i; i--) {
    for (int j = 0; j < m; j++)
      if (id[i] && (i & (1 << j))) id[i ^ (1 << j)] = id[i];
  }
  for (int i = 0; i < (1 << m); i++)
    if (id[i] && id[((1 << m) - 1) ^ i]) {
      ans1 = id[i];
      ans2 = id[((1 << m) - 1) ^ i];
      return 1;
    }
  return 0;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  }
  int L = 0, R = 1e9;
  while (L < R) {
    int mid = (L + R + 1) / 2;
    if (check(mid))
      L = mid;
    else
      R = mid - 1;
  }
  check((L + R) / 2);
  printf("%d %d\n", ans1, ans2);
  return 0;
}
