#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 3e5 + 5;
int vis[260];
int a[N][10];
int n, m;
int x, y;
bool check(int key) {
  int t;
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= n; i++) {
    t = 0;
    for (int j = 1; j <= m; j++) {
      if (a[i][j] >= key) {
        t += 1 << (j - 1);
      }
    }
    vis[t] = i;
  }
  for (int i = 0; i <= 256; i++) {
    for (int j = 0; j <= 256; 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;
    } else
      r = mid - 1;
  }
  printf("%d %d\n", x, y);
  return 0;
}
