#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5, M = 8 + 2;
int a[MAXN][M], mark[1 << M];
pair<int, int> ans;
int n, m;
void input();
bool check(int);
void solve();
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  input();
  solve();
  return 0;
}
void input() {
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
}
bool check(int x) {
  for (int i = 0; i < n; i++) {
    int ksh = 0;
    for (int j = 0; j < m; j++)
      if (a[i][j] >= x) ksh += 1 << j;
    mark[ksh] = i + 1;
  }
  bool p = false;
  for (int i = 0; i < 1 << m; i++)
    for (int j = i; j < 1 << m; j++)
      if ((i | j) == (1 << m) - 1 && mark[i] && mark[j]) {
        p = true;
        ans = {mark[i], mark[j]};
      }
  for (int i = 0; i < 1 << m; i++) mark[i] = 0;
  return p;
}
void solve() {
  int l = 0, r = 1e9 + 9, mid = (l + r) / 2;
  ans = {1, 1};
  while (r - l > 1) {
    check(mid) ? l = mid : r = mid;
    mid = (l + r) / 2;
  }
  cout << ans.first << " " << ans.second << endl;
}
