#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 7;
int n, m, a[N][8];
signed main() {
  ios::sync_with_stdio(false);
  cin.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 l = 0, r = 1e9, x, y;
  while (l <= r) {
    int mid = (l + r) / 2;
    vector<int> exist((1 << m), -1);
    for (int i = 0; i < n; ++i) {
      int mask = 0;
      for (int j = 0; j < m; ++j) {
        if (a[i][j] >= mid) mask |= (1 << j);
      }
      exist[mask] = i;
    }
    bool ok = false;
    for (int i = 0; i < (1 << m); ++i) {
      for (int j = 0; j < (1 << m); ++j) {
        ok |= (exist[i] != -1 && exist[j] != -1 && ((i | j) == (1 << m) - 1));
        if (ok) {
          x = exist[i] + 1, y = exist[j] + 1;
          break;
        }
      }
      if (ok) break;
    }
    if (ok)
      l = mid + 1;
    else
      r = mid - 1;
  }
  cout << x << " " << y;
}
