#include <bits/stdc++.h>
using namespace std;
const int N_MAX = 3e5, M_MAX = 8;
int n, m, a[N_MAX][M_MAX];
set<int> st;
vector<int> val;
int ki[1 << M_MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
      st.insert(a[i][j]);
    }
  }
  val = vector<int>(st.begin(), st.end());
  int l = 0, r = val.size() - 1;
  while (l < r) {
    int k = (l + r + 1) / 2;
    for (int i = 0; i < (1 << m); i++) ki[i] = -1;
    for (int i = 0; i < n; i++) {
      int x = 0;
      for (int j = 0; j < m; j++) {
        x *= 2;
        if (a[i][j] < val[k]) x++;
      }
      ki[x] = i;
    }
    bool ok = false;
    if (ki[0] != -1) ok = true;
    for (int i = 0; !ok && i < (1 << m); i++) {
      if (ki[i] == -1) continue;
      for (int j = i + 1; !ok && j < (1 << m); j++) {
        if (ki[j] != -1 && (i & j) == 0) ok = true;
      }
    }
    if (ok)
      l = k;
    else
      r = k - 1;
  }
  for (int i = 0; i < (1 << m); i++) ki[i] = -1;
  for (int i = 0; i < n; i++) {
    int x = 0;
    for (int j = 0; j < m; j++) {
      x *= 2;
      if (a[i][j] < val[l]) x++;
    }
    ki[x] = i;
  }
  if (ki[0] != -1) {
    cout << ki[0] + 1 << " " << ki[0] + 1 << "\n";
    return 0;
  }
  for (int i = 0; i < (1 << m); i++) {
    if (ki[i] == -1) continue;
    for (int j = i + 1; j < (1 << m); j++) {
      if (ki[j] != -1 && (i & j) == 0) {
        cout << ki[i] + 1 << " " << ki[j] + 1 << "\n";
        return 0;
      }
    }
  }
  return 0;
}
