#include <bits/stdc++.h>
using namespace std;
long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, -1, 1};
pair<long long, long long> dp[256];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  vector<vector<long long>> v(n, vector<long long>(m, 0));
  long long t = 1ll << m;
  for (long long i = 1; i < t; ++i) dp[i] = {-1, -1};
  for (auto &k : v)
    for (auto &i : k) cin >> i;
  for (long long i = 0; i < n; ++i) {
    for (long long j = 1; j < t; ++j) {
      long long mn = INT_MAX;
      for (long long k = 0; k < m; ++k) {
        if (j & (1 << k)) {
          mn = min(mn, v[i][k]);
        }
      }
      if (dp[j].first <= mn) {
        dp[j].first = mn;
        dp[j].second = i;
      }
    }
  }
  pair<long long, long long> ans = {-1, -1};
  long long mx = -1;
  for (long long i = 1; i < t; ++i) {
    for (long long j = i; j < t; ++j) {
      long long p = i | j;
      if (p == t - 1 and min(dp[i].first, dp[j].first) >= mx) {
        mx = min(dp[i].first, dp[j].first);
        ans.first = dp[i].second;
        ans.second = dp[j].second;
      }
    }
  }
  cout << ans.first + 1 << " " << ans.second + 1;
}
