#include<bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;
using Mat = vector<vll>;
const char ent = '\n';

ll value(int r, int c);

pii find_locmin_point(int n, int m) {
	Mat a(n, vll(m));
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			a[i][j] = value(i + 1, j + 1);
		}
	}
	
	auto check = [&] (int x, int y) {
		return x >= 0 && x < n && y >= 0 && y < m;
	};
	
	vi dx = {0, 0, 1, -1};
	vi dy = {1, -1, 0, 0};
	for (int i=0; i<n; i++) {
		for (int j=0; j<m; j++) {
			bool ok = true;
			for (int d=0; d<4; d++) {
				int x = i + dx[d];
				int y = j + dy[d];
				if (check(x, y)) {
					if (a[x][y] > a[i][j]) ok = false;
				}
			}
			if (ok) {
				return {i + 1, j + 1};
			}
		}
	}
	//assert(false);
}