#include <bits/stdc++.h>
std::pair<int, int> DR[] = {{-1, 0}, {0, 1},   {1, 0}, {0, -1},
                            {-1, 1}, {-1, -1}, {1, 1}, {1, -1}};
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  ~debug() { cerr << endl; }
  template <class c>
  typename enable_if<sizeof dud<c>(0) != 1, debug&>::type operator<<(c i) {
    cerr << boolalpha << i;
    return *this;
  }
  template <class c>
  typename enable_if<sizeof dud<c>(0) == 1, debug&>::type operator<<(c i) {
    return *this << range(begin(i), end(i));
  }
  template <class c, class b>
  debug& operator<<(pair<b, c> d) {
    return *this << "(" << d.first << ", " << d.second << ")";
  }
  template <class c>
  debug& operator<<(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it;
    return *this << "]";
  }
};
int gcd(int a, int b) {
  if (b) return gcd(b, a % b);
  return a;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
pair<int, int> val[1 << 19];
int n, m, a[1 << 19][10];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  int fullmask = (1 << m) - 1;
  for (int mask = 0; mask < (1 << m); mask++) {
    vector<int> pos;
    for (int j = 0; j < m; j++) {
      if (mask & (1 << j)) pos.push_back(j);
    }
    pair<int, int> mx;
    for (int i = 0; i < n; i++) {
      int mn = 1e9;
      for (auto it : pos) {
        mn = min(mn, a[i][it]);
      }
      if (!i) mx = make_pair(mn, i);
      mx = max(mx, make_pair(mn, i));
    }
    val[mask] = mx;
  }
  pair<int, pair<int, int>> ans = make_pair(-1, make_pair(0, 0));
  for (int mask = 0; mask <= fullmask; mask++) {
    ans = max(ans, make_pair(min(val[mask].first, val[fullmask - mask].first),
                             make_pair(val[mask].second,
                                       val[fullmask - mask].second)));
  }
  cout << ans.second.first + 1 << ' ' << ans.second.second + 1 << '\n';
}
