#include <bits/stdc++.h>

using namespace std;

using ll=long long;

ll fpow(ll a, ll b) {
    ll ans = 1;
    for (; b; b >>= 1, a *= a)
        if (b & 1)
            ans *= a;
    return ans;
}

int sel(int n, int k) {
    vector<string> v(n);
    for (int i = 1; i <= n; i++)
        v[i - 1] = to_string(i);
    nth_element(v.begin(), v.begin() + k - 1, v.end());
    return atoi(v[k - 1].c_str());
}

int main() {
    for (;;) {
        int m, k;
        cin >> m >> k;

    }
    int T, k, m;
    scanf("%d", &T);
    while (T--) {
        scanf("%d%d", &k, &m);
    }
    return 0;
}