#include <bits/stdc++.h>
using namespace std;
const int N = (int)3e5 + 1;
int n, m, a[N][10], p1 = 1, p2 = 1;
int ok[(1 << 8) + 1];
bool check(int x) {
  memset(ok, 0, sizeof(ok));
  for (int i = 1; i <= n; ++i) {
    int mask = 0;
    for (int j = 0; j < m; ++j) {
      if (a[i][j] >= x) mask |= (1 << j);
    }
    for (int j = 0; j < (1 << m); ++j) {
      if (ok[j] && (mask | j) == (1 << m) - 1) {
        p1 = ok[j];
        p2 = i;
        return true;
      }
    }
    ok[mask] = i;
  }
  return false;
}
void solve() {
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < m; ++j) cin >> a[i][j];
  }
  int l = 0, r = (int)1e9;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (check(mid)) {
      l = mid + 1;
    } else
      r = mid - 1;
  }
  cout << p1 << " " << p2;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
