#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5, M = 10;
int n, m, a[N][M], b[N], t[1 << M], x, y;
inline bool check(int mid) {
  memset(b, 0, sizeof b);
  memset(t, 0, sizeof t);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) b[i] = (b[i] << 1) | (a[i][j] >= mid);
    t[b[i]] = i;
  }
  for (int i = 1; i < (1 << m); i++)
    for (int j = 1; j < (1 << m); j++)
      if ((i | j) == (1 << m) - 1 && t[i] && t[j]) {
        x = t[i];
        y = t[j];
        return true;
      }
  return false;
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  int lb = -1, rb = 1e9;
  while (lb < rb) {
    int mid = lb + rb + 1 >> 1;
    if (check(mid))
      lb = mid;
    else
      rb = mid - 1;
  }
  cout << x << ' ' << y << endl;
  return 0;
}
