#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, m;
int a[maxn][10];
int mask[maxn];
int valid[1024];
pair<int, int> ans;
void print(int x) {
  for (int i = 7; i >= 0; i--) cout << ((x >> i) & 1);
  puts("");
}
bool check(int x) {
  memset(valid, -1, sizeof(valid));
  memset(mask, 0, sizeof(mask));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (a[i][j] >= x) mask[i] |= (1 << j);
    valid[mask[i]] = i;
  }
  for (int i = 0; i < (1 << m); i++) {
    if (valid[i] == -1) continue;
    for (int j = 0; j < (1 << m); j++)
      if (((i | j) == ((1 << m) - 1)) && valid[j] != -1) {
        ans = make_pair(valid[i], valid[j]);
        return true;
      }
  }
  return false;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  int l = 0, r = 1e9;
  while (l < r) {
    int mid = l + r + 1 >> 1;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  check(l);
  printf("%d %d", ans.first + 1, ans.second + 1);
  return 0;
}
