#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int> > a(3e5, vector<int>(8));
int in1, in2;
bool check(int x) {
  map<int, int> s;
  for (int i = 0; i < n; i++) {
    int mask = 0;
    for (int j = 0; j < m; j++) mask |= ((a[i][j] >= x) << j);
    s[mask] = i;
  }
  for (auto i : s) {
    for (auto j : s)
      if ((i.first | j.first) == (1 << m) - 1) {
        in1 = i.second, in2 = j.second;
        return true;
      }
  }
  return false;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  int low = 0, high = (int)10e9;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (check(mid)) {
      if (!check(mid + 1)) break;
      low = mid + 1;
    } else
      high = mid - 1;
  }
  cout << in1 + 1 << " " << in2 + 1 << "\n";
  return 0;
}
