#include <bits/stdc++.h>
using namespace std;
template <typename T>
void read(T &x) {
  cin >> x;
}
template <typename T, typename T0>
void read(T &x, T0 &y) {
  cin >> x >> y;
}
template <typename T, typename T0, typename T1>
void read(T &x, T0 &y, T1 &z) {
  cin >> x >> y >> z;
}
template <typename T, typename T0, typename T1, typename T2>
void read(T &x, T0 &y, T1 &z, T2 &w) {
  cin >> x >> y >> z >> w;
}
template <typename T, typename T0>
void read(pair<T, T0> &p) {
  cin >> p.first >> p.second;
}
template <typename T>
void read(vector<T> &oneD) {
  for (long long i = 0; i < oneD.size(); i++) {
    read(oneD[i]);
  }
}
template <typename T>
void read(T oneD[], int n) {
  for (long long i = 0; i < n; i++) {
    read(oneD[i]);
  }
}
template <typename T>
void write(T &x) {
  cout << x << " ";
}
template <typename T, typename T0>
void write(T &x, T0 &y) {
  cout << x << " " << y << "\n";
}
template <typename T, typename T0, typename T1>
void write(T &x, T0 &y, T1 &z) {
  cout << x << " " << y << " " << z << "\n";
}
template <typename T, typename T0, typename T1, typename T2>
void write(T &x, T0 &y, T1 &z, T2 &w) {
  cout << x << " " << y << " " << z << " " << w << "\n";
}
template <typename T, typename T0>
void write(pair<T, T0> &p) {
  write(p.first);
  write(p.second);
  cout << "\n";
}
template <typename T>
void write(vector<T> &oneD) {
  for (long long i = 0; i < oneD.size(); i++) {
    write(oneD[i]);
  }
  cout << "\n";
}
template <typename T>
void write(T oneD[], int n) {
  for (long long i = 0; i < n; i++) {
    write(oneD[i]);
  }
  cout << "\n";
}
template <typename T, typename T0>
void write(map<T, T0> &mpp) {
  for (auto it : mpp) {
    write(it.first);
    cout << ": ";
    write(it.second);
    cout << "\n";
  }
  cout << "\n";
}
vector<long long> sieve;
void Sieve(int N) {
  const long long maxn = N;
  sieve.resize(maxn);
  for (long long(i) = 0; (i) < (maxn); ++(i)) sieve[i] = i;
  sieve[1] = -1;
  sieve[0] = -1;
  for (long long(i) = 2; (i) <= (maxn); (i) += (1))
    if (i == sieve[i])
      for (long long j = 2 * i; j < maxn; j += i)
        if (sieve[j] == j) sieve[j] = i;
}
long long extended_GCD(long long a, long long b, long long &x, long long &y) {
  if (a == 0) {
    x = 0;
    y = 1;
    return b;
  }
  long long x1, y1;
  long long gcd = extended_GCD(b % a, a, x1, y1);
  x = y1 - (b / a) * x1;
  y = x1;
  return gcd;
}
long long power(long long a, long long b, long long m = 1000000007) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % m;
    a = a * a % m;
    b >>= 1;
  }
  return res;
}
long long modinv(long long a, long long mod = 1000000007) {
  long long x, y;
  extended_GCD(a, mod, x, y);
  if (x < 0) x += mod;
  return x;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int> > A(n, vector<int>(m));
  vector<pair<int, int> > maskMax(1 << m);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> A[i][j];
    }
    for (int mask = 0; mask < 1 << m; ++mask) {
      pair<int, int> cur = {INT_MAX, -1};
      for (int j = 0; j < m; ++j) {
        if ((mask >> j) & 1 == 1) {
          cur = min(cur, {A[i][j], i});
        }
      }
      maskMax[mask] = max(maskMax[mask], cur);
    }
  }
  int s = 0, e = 1e9;
  int ans = -1, resI = -1, resJ = -1;
  while (s <= e) {
    int mid = s + e >> 1;
    bool possible = false;
    int curI = -1, curJ = -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;
        }
      }
      if (maskMax[mask].first >= mid) {
        possible = true;
        curI = i;
        curJ = maskMax[mask].second;
        if (curJ == -1) curJ = i;
        break;
      }
    }
    if (possible) {
      s = mid + 1;
      ans = mid;
      resI = curI;
      resJ = curJ;
    } else {
      e = mid - 1;
    }
  }
  cout << resI + 1 << " " << resJ + 1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
