#include <bits/stdc++.h>

using namespace std;

using ll = long long;

ll value(int r, int c);

const int NMAX = 505;
const ll INF = 1.1e18;

#define check(pos) if (query(1, pos) < query(1, pos + 1) && query(1, pos) < query(1, pos - 1)) return { 1, (pos) }

int n, m;
ll a[NMAX][NMAX];

ll query(int x, int y) {
   if (x < 1 || y < 1 || x > n || y > m) return INF;
   return a[x][y] ? a[x][y] : a[x][y] = value(x, y);
}

pair<int, int> find_locmin_point(int N, int M) {
   n = N;
   m = M;
   int l = 1, r = m;

   while (l <= r) {
      int mid = (l + r) / 2;
      if (query(1, mid) < query(1, mid + 1)) {
         r = mid;
         check(mid);
      } else {
         l = mid;
         check(mid + 1);
      }
   }

   check(r + 1);
   return { 1, r };
}

#ifdef LOCAL

ll _a[NMAX][NMAX];
ll value(int r, int c) {
   return _a[r][c];
}

signed main() {
   freopen("input.txt", "r", stdin);
   int n, m;
   cin >> n >> m;
   for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
         cin >> _a[i][j];
      }
   }
   auto [ x, y ] = find_locmin_point(n, m);
   cout << x << ' ' << y << endl;
   return 0;
}

#endif
