#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[300005][8];
int a1, a2;
bool check(int x) {
  vector<int> mask(1 << m, -1);
  for (int i = 0; i < n; i++) {
    int now = 0;
    for (int j = 0; j < m; j++) {
      if (a[i][j] >= x) {
        now |= (1 << j);
      }
    }
    mask[now] = i;
  }
  if (mask[(1 << m) - 1] != -1) {
    a1 = a2 = mask[(1 << m) - 1];
    return true;
  }
  for (int i = 0; i < (1 << m); i++) {
    for (int j = 0; j < (1 << m); j++) {
      if (mask[i] != -1 && mask[j] != -1 && (i | j) == (1 << m) - 1) {
        a1 = mask[i];
        a2 = mask[j];
        return true;
      }
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.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;
  int r = 1e9 + 100;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (check(mid))
      l = mid;
    else
      r = mid;
  }
  cout << a1 + 1 << ' ' << a2 + 1 << '\n';
  return 0;
}
