#include <bits/stdc++.h>
constexpr int maxn = 3e5 + 5;
int a[maxn][10], ans, res, x, y, n, m;
bool check(int mid) {
  int vis[2000] = {0};
  for (int i = 1; i <= n; i++) {
    int tmp = 0;
    for (int j = 1; j <= m; j++)
      if (a[i][j] >= mid) tmp += (1 << (j - 1));
    vis[tmp] = i;
  }
  for (int i = 0; i < (1 << m); i++)
    for (int j = 0; j < (1 << m); j++)
      if (vis[i] && vis[j] && (i | j) == (1 << m) - 1) {
        x = vis[i], y = vis[j];
        return true;
      }
  return false;
}
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]);
  int l = 0, r = 1e9;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1, ans = x, res = y;
    else
      r = mid - 1;
  }
  printf("%d %d\n", ans, res);
  return 0;
}
