#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5;
int n, m, a[maxn + 10][20], ans1, ans2;
int check(int mid) {
  static int cnt, bucket[500], s[maxn + 10], pos[20];
  memset(bucket, 0, sizeof(bucket));
  memset(s, 0, sizeof(s));
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j)
      if (a[i][j] >= mid) s[i] |= 1 << (j - 1);
  for (int i = 1; i <= n; ++i) bucket[s[i]] = i;
  for (int i = 1; i <= n; ++i) {
    cnt = 0;
    for (int j = 1; j <= m; ++j)
      if (a[i][j] >= mid) pos[++cnt] = j;
    for (int j = 0; j < (1 << cnt); ++j) {
      int res = 0;
      for (int k = 1; k <= cnt; ++k)
        if (j & (1 << (k - 1))) res |= 1 << (pos[k] - 1);
      res |= ((1 << m) - 1) - s[i];
      if (bucket[res]) {
        ans1 = i;
        ans2 = bucket[res];
        return 1;
      }
    }
  }
  return 0;
}
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, ans;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  printf("%d %d\n", ans1, ans2);
  return 0;
}
