#include <bits/stdc++.h>
long long z = 1000000007;
using namespace std;
long long n, m, ans = 0;
long long arr[300005][8];
pair<long long, long long> g;
long long l, r, mid;
void check() {
  if (l > r) return;
  int flag = 0;
  long long val[n];
  for (long long i = 0; i < n; i++) val[i] = 0;
  long long curr = 1;
  for (long long i = 0; i < m; i++) {
    for (long long j = 0; j < n; j++) {
      if (arr[j][i] >= mid) {
        val[j] += curr;
      }
    }
    curr *= 2;
  }
  map<long long, long long> ma;
  for (long long i = 0; i < n; i++) {
    ma[val[i]] = 1;
  }
  long long upp = pow(2, m);
  long long ans_1 = 0, ans_2 = 0;
  for (long long i = 0; i < upp; i++) {
    for (long long j = 0; j < upp; j++) {
      if ((ma[i] == 1) && (ma[j] == 1) && ((i | j) == (upp - 1))) {
        flag = 1;
        ans_1 = i;
        ans_2 = j;
        break;
      }
    }
    if (flag) break;
  }
  if (flag == 0) {
    r = mid - 1;
    mid = (l + r) / 2;
    check();
  } else {
    for (long long i = 0; i < n; i++) {
      if (val[i] == ans_1) {
        g.second = i;
      }
      if (val[i] == ans_2) g.first = i;
    }
    l = mid + 1;
    mid = (l + r) / 2;
    check();
  }
  return;
}
int main() {
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  l = 0, r = 1000000000;
  mid = (l + r) / 2;
  check();
  cout << g.first + 1 << ' ' << g.second + 1 << endl;
  return 0;
}
