#include <bits/stdc++.h>
using namespace std;
long long nxt() {
  long long x;
  cin >> x;
  return x;
}
void setIO(string s) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
const long long mod = 1e9 + 7;
void yes() { cout << "YES\n"; }
void no() { cout << "NO\n"; }
bool possible(long long mid, long long n, long long m,
              vector<vector<long long> > &a, long long &I, long long &J) {
  long long max_mask = 1 << m;
  vector<long long> bit_present(max_mask, -1);
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    long long cur_bit = 0;
    long long looking_for = 0;
    long long bit_cnt_looking_for = 0;
    for (long long j = (long long)(0); j < (long long)(m); j++) {
      if (a[i][j] >= mid)
        cur_bit |= (1 << j);
      else {
        looking_for |= (1 << j);
        bit_cnt_looking_for++;
      }
    }
    bit_present[cur_bit] = i;
    for (long long j = (long long)(0); j < (long long)(max_mask); j++) {
      if ((j & looking_for) == looking_for && bit_present[j] != -1) {
        I = bit_present[j];
        J = i;
        return 1;
      }
    }
  }
  return 0;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  vector<vector<long long> > a(n, vector<long long>(m));
  for (long long i = (long long)(0); i < (long long)(n); i++)
    for (long long j = (long long)(0); j < (long long)(m); j++) cin >> a[i][j];
  long long lo = 0, hi = 1000 * 1000 * 1000 + 5;
  long long I = 0, J = 0;
  while (lo < hi) {
    long long mid = (lo + hi + 1) / 2;
    if (possible(mid, n, m, a, I, J)) {
      lo = mid;
    } else {
      hi = mid - 1;
    }
  }
  42;
  cout << I + 1 << " " << J + 1 << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed << setprecision(10);
  long long T = 1;
  for (long long tc = 1; tc <= T; tc++) {
    solve();
  }
}
