#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long INFLL = 1e18;
const long long MOD = 1000000007;
const long double eps = 1e-6;
const long double eps2 = 1e-9;
const long long MOD2 = 998244353;
const long long dosz = 5e5;
const long long SZ = (1 << 18);
const long double PI = atan2l(0, -1);
void fast_io() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
const int maxn = 3e5 + 228;
int n, m;
int kek[maxn][10];
pair<int, int> check(int mid) {
  vector<int> mask((1 << m), -1);
  for (int i = 0; i < n; i++) {
    int cur_mask = 0;
    for (int j = 0; j < m; j++) {
      if (kek[i][j] >= mid) {
        cur_mask |= (1 << j);
      }
    }
    for (int j = 0; j < (1 << m); j++) {
      if ((j | cur_mask) == ((1 << m) - 1)) {
        if (mask[j] != -1) {
          return make_pair(mask[j], i);
        }
      }
    }
    mask[cur_mask] = i;
  }
  return make_pair(-1, -1);
}
void solve() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> kek[i][j];
    }
  }
  int l = 0, r = 1e9;
  pair<int, int> ans;
  while (l <= r) {
    int mid = (l + r) / 2;
    pair<int, int> lol = check(mid);
    if (lol.first == -1 && lol.second == -1) {
      r = mid - 1;
    } else {
      ans = lol;
      l = mid + 1;
    }
  }
  cout << ans.first + 1 << " " << ans.second + 1 << '\n';
}
signed main() {
  fast_io();
  int q = 1;
  while (q--) {
    solve();
  }
  return 0;
}
