#include <bits/stdc++.h>
using namespace std;
vector<int> vec[300005];
int minv[2686];
int n, m;
int lst;
bool ok(int x) {
  for (int i = 0; i < n; ++i) {
    int k = 0;
    for (int j = 0; j < m; ++j) {
      if (vec[i][j] < x) {
        k |= (1 << j);
      }
    }
    if (!k || minv[k] >= x) {
      lst = i;
      return 1;
    }
  }
  return 0;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    vec[i].resize(m);
    for (int j = 0; j < m; ++j) {
      scanf("%d", &vec[i][j]);
    }
    for (int k = 0; k < (1 << m); ++k) {
      int tmp = 1e9;
      for (int j = 0; j < m; ++j) {
        if ((1 << j) & k) {
          tmp = min(tmp, vec[i][j]);
        }
      }
      minv[k] = max(tmp, minv[k]);
    }
  }
  int low = -1, high = 1e9 + 3;
  while (high - low > 1) {
    int mid = (low + high) >> 1;
    if (ok(mid)) {
      low = mid;
    } else {
      high = mid;
    }
  }
  int k = 0;
  for (int j = 0; j < m; ++j) {
    if (vec[lst][j] < low) {
      k |= (1 << j);
    }
  }
  for (int i = 0; i < n; ++i) {
    bool kd = 1;
    for (int j = 0; j < m; ++j) {
      if (k & (1 << j)) {
        if (vec[i][j] < low) {
          kd = 0;
          break;
        }
      }
    }
    if (kd) {
      cout << lst + 1 << " " << i + 1 << endl;
      return 0;
    }
  }
  cout << 1 << " " << 1;
  return 0;
}
