#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e5 + 5;
const int MAX_M = 8;
const long long INF = 1e9 + 5;
void solve();
int main() {
  solve();
  return 0;
}
int n, m;
long long a[MAX_N][MAX_M];
int vec[1 << MAX_M];
pair<int, int> check(long long x) {
  for (int i = 0; i < (1 << m); ++i) vec[i] = -1;
  for (int i = 0; i < n; ++i) {
    int cur = 0;
    for (int j = 0; j < m; ++j)
      if (a[i][j] >= x) cur |= (1 << j);
    for (int s = cur;; s = ((s - 1) & cur)) {
      vec[s] = i;
      if (s == 0) break;
    }
    int c = (1 << m) - 1 - cur;
    if (vec[c] != -1) {
      return make_pair(i + 1, vec[c] + 1);
    }
  }
  return make_pair(-1, -1);
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> a[i][j];
  long long l = 0;
  long long r = INF;
  while (r - l > 1) {
    long long m = (l + r) / 2;
    pair<int, int> cur = check(m);
    if (cur.first != -1)
      l = m;
    else
      r = m;
  }
  pair<int, int> ans = check(l);
  cout << ans.first << ' ' << ans.second << '\n';
  return;
}
