#include <bits/stdc++.h>
using namespace std;
const int N = 3 * 1e5, M = 8;
int n, m;
int a[N + 5][M + 5];
int mx, ansx, ansy;
int tmpx, tmpy;
int b[N + 5], d[(1 << M) + 5];
inline int read() {
  int x = 0, ff = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') ff = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * ff;
}
bool able(int x) {
  memset(b, 0, sizeof(b));
  memset(d, 0, sizeof(d));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (a[i][j] >= x) b[i] |= (1 << j);
      d[b[i]] = i + 1;
    }
  for (int i = 0; i < n; i++)
    for (int j = 1; j < (1 << m); j++)
      if (d[j] && (b[i] | j) == (1 << m) - 1) {
        tmpx = i + 1;
        tmpy = d[j];
        return 1;
      }
  return 0;
}
int main() {
  n = read(), m = read();
  int l = 0, r = 0, mid;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      a[i][j] = read();
      r = max(a[i][j], r);
    }
  while (l <= r) {
    mid = (l + r) / 2;
    if (able(mid)) {
      mx = mid;
      ansx = tmpx, ansy = tmpy;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  if (mx > 0)
    cout << ansx << " " << ansy << endl;
  else
    cout << "1 1\n";
  return 0;
}
