#include <bits/stdc++.h>
const int N = 300000;
const int M = 8;
int n, m, a[N][M];
std::pair<bool, std::pair<int, int> > test(int v) {
  std::pair<int, int> x[N];
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) x[i].first |= (a[i][j] >= v) << j;
    x[i].second = i;
  }
  std::sort(x, x + n);
  for (int i = 0; i < 1 << m; ++i)
    for (int j = 0; j < 1 << m; ++j)
      if ((i | j) == (1 << m) - 1) {
        int f = std::lower_bound(x, x + n, std::make_pair(i, 0)) - x,
            s = std::lower_bound(x, x + n, std::make_pair(j, 0)) - x;
        if (f != n && x[f].first == i && s != n && x[s].first == j)
          return std::make_pair(true, std::make_pair(x[f].second, x[s].second));
      }
  return std::make_pair(false, std::make_pair(0, 0));
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", a[i] + j);
  int l = 0, r = 1000000000;
  std::pair<int, int> ans;
  while (l <= r) {
    int m = (l + r) >> 1;
    std::pair<bool, std::pair<int, int> > p;
    if ((p = test(m)).first) {
      ans = p.second;
      l = m + 1;
    } else
      r = m - 1;
  }
  printf("%d %d\n", ans.first + 1, ans.second + 1);
  return 0;
}
