#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 20, M = 10;
int n, m, a[N][M], vis[1 << M], w[M], ans1, ans2;
bool fun(int v) {
  int en = 1 << m;
  for (int i = 0; i < en; i++) vis[i] = -1;
  for (int i = 1; i <= n; i++) {
    int t = 0;
    for (int j = 1; j <= m; j++)
      if (a[i][j] >= v) t += w[j];
    vis[t] = i;
  }
  for (int i = 0; i < en; i++)
    for (int j = i; j < en; j++)
      if (vis[i] != -1 && vis[j] != -1 && (i | j) == en - 1) {
        ans1 = vis[i], ans2 = vis[j];
        return 1;
      }
  return 0;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  w[1] = 1;
  for (int i = 2; i < M; i++) w[i] = w[i - 1] << 1;
  int l = 0, r = 1e9 + 10;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (fun(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << ans1 << ' ' << ans2 << endl;
  return 0;
}
