#include <bits/stdc++.h>
using namespace std;
inline long long gcd(long long a, long long b) {
  while (b != 0) {
    long long c = a % b;
    a = b;
    b = c;
  }
  return a < 0 ? -a : a;
}
inline long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
inline long long lowbit(long long x) { return x & (-x); }
const double PI = 3.14159265358979323846;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const long long mod = 998244353;
inline char nc() {
  static char buf[1000000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long rd() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = (x << 3) + (x << 1) + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
const double eps = 1e-8;
const int M = 4e6 + 10;
const int N = 3e5 + 10;
int a[N][10];
int n, m;
int f[1 << 9];
int m1, m2;
int maxx;
bool check(int x) {
  memset(f, 0, sizeof f);
  for (int i = 1; i <= n; i++) {
    int res = 1;
    int sum = 0;
    for (int j = 0; j < m; j++) {
      if (a[i][j] >= x) sum += res;
      res <<= 1;
    }
    f[sum] = i;
  }
  for (int i = 1; i <= maxx; i++) {
    if (!f[i]) continue;
    for (int j = i; j <= maxx; j++) {
      if (!f[j]) continue;
      if ((i | j) == maxx) {
        m1 = f[i];
        m2 = f[j];
        return 1;
      }
    }
  }
  return 0;
}
int main() {
  n = rd(), m = rd();
  m1 = m2 = 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      a[i][j] = rd();
    }
  }
  maxx = (1 << m) - 1;
  int l = 0, r = 1e9;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (check(mid))
      l = mid;
    else
      r = mid - 1;
  }
  printf("%d %d\n", m1, m2);
}
