#include <bits/stdc++.h>
using namespace std;
int n, m;
string ve[500];
int v[300005][10];
int poz[500];
unordered_set<string> us;
int sol, x1, x2;
bool se_pupa(string a, string b) {
  for (int i = 0; i < m; i++)
    if (a[i] + b[i] - '0' - '0' == 0) return false;
  return true;
}
bool valid(int val) {
  us.clear();
  int contor = 0;
  for (int i = 1; i <= n; i++) {
    string str = "";
    for (int j = 1; j <= m; j++) {
      if (v[i][j] >= val) {
        str += '1';
      } else
        str += '0';
    }
    if (us.count(str) == 0) {
      us.insert(str);
      ve[++contor] = str;
      poz[contor] = i;
    }
  }
  for (int i = 1; i <= contor; i++) {
    for (int j = i; j <= contor; j++) {
      if (se_pupa(ve[i], ve[j]) == true) {
        x1 = poz[i];
        x2 = poz[j];
        return true;
      }
    }
  }
  return false;
}
void cb(int st, int dr) {
  if (st > dr) return;
  int mid = (st + dr) / 2;
  if (valid(mid) == true) {
    sol = mid;
    cb(mid + 1, dr);
  } else
    cb(st, mid - 1);
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) cin >> v[i][j];
  }
  cb(0, 1000000000);
  cout << x1 << " " << x2;
  return 0;
}
