#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int N = 3 * (1e5) + 2;
int arr[N][8];
int n, m;
pair<int, int> pos(int val) {
  map<int, int> make_pair;
  for (int i = 0; i < n; ++i) {
    int mask = 0;
    for (int j = 0; j < m; ++j) {
      if (arr[i][j] >= val) mask |= 1 << j;
    }
    make_pair[mask] = i;
  }
  int need = 1;
  for (int i = 0; i < m; ++i) need *= 2;
  int mx = 0;
  for (auto in1 : make_pair) {
    for (auto in2 : make_pair) {
      mx = max(mx, in1.first | in2.first);
      if ((in1.first | in2.first) + 1 == need) return {in1.second, in2.second};
    }
  }
  return {-1, -1};
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> arr[i][j];
    }
  }
  pair<int, int> fn = {-1, -1};
  int st = 0, end = 1e9;
  while (st < end) {
    int mid = st + (end - st + 1) / 2;
    fn = pos(mid);
    if (fn.first != -1)
      st = mid;
    else
      end = mid - 1;
  }
  fn = pos(st);
  cout << fn.first + 1 << " " << fn.second + 1;
}
