#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(i, j) \
   if (int val = query(i, j); val < query(i + 1, j) && val < query(i - 1, j) && val < query(i, j + 1) && val < query(i, j - 1)) return { i, j }

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(1, mid);
      } else {
         l = mid;
         check(1, mid + 1);
      }
   }

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

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

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

   return { n, m };
}

#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
