#include <bits/stdc++.h>
using namespace std;
function<void(void)> ____ = []() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
};
const int MAXN = 3e5 + 7;
int n, m, mat[MAXN][10];
bool check(int mid) {
  unordered_set<int> S;
  for (int i = 1; i <= n; i++) {
    int msk = 0;
    for (int j = 1; j <= m; j++)
      if (mat[i][j] >= mid) msk |= (1 << (j - 1));
    S.insert(msk);
    for (auto x : S)
      if ((x | msk) == ((1 << m) - 1)) return true;
  }
  return false;
}
int main() {
  scanf("%d %d", &n, &m);
  int l = 0, r = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%d", &mat[i][j]);
      r = max(r, mat[i][j]);
    }
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid))
      l = mid + 1;
    else
      r = mid - 1;
  }
  unordered_map<int, int> mp;
  for (int i = 1; i <= n; i++) {
    int msk = 0;
    for (int j = 1; j <= m; j++)
      if (mat[i][j] >= r) msk |= (1 << (j - 1));
    mp.insert(make_pair(msk, i));
    for (auto x : mp)
      if ((x.first | msk) == ((1 << m) - 1)) {
        cout << x.second << ' ' << i << endl;
        return 0;
      }
  }
  return 0;
}
