#include <bits/stdc++.h>
using namespace std;

long long value(int r, int c);

struct Gridrememberer {
    Gridrememberer(int n, int m) : size(n, vector<long long>(m, -1)), x(n), y(m) {}

    long long get_value(int n, int m) {
        if (n < 0 || m < 0 || n >= x || m >= y) {
            return 10'000'0000;
        }

        if (size[n][m] != -1) {
            return size[n][m];
        }

        return size[n][m] = value(n + 1, m + 1);
    }

    vector<vector<long long>> size;

    int x, y;
};

std::pair<int, int> find_locmin_point(int n, int m) {
    Gridrememberer grid(n, m);
    
    int mi = 0;
    int ma = m;

    while (mi + 1 < ma) {
        int mid = (mi + ma) / 2;

        if (grid.get_value(0, mid - 1) < grid.get_value(0, mid)) {
            ma = mid;
        } else {
            mi = mid;
        }
    }

    return {0 + 1, mi + 1};
}