#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt,tune=native")
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
#define ll long long
#define ld long double
#define en exit(0);
#define pb push_back
#define fi first
#define se second
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
pair<int,int> dd[] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
map<array<int, 3>, int> mp;
int n, m, k, q;
int ask(int x, int y = 1, int z = 1)
{
    if(min({x, y, z}) < 1 || x > n || y > m || z > k)
        return 0;
    array<int, 3> tmp = {x, y, z};
    if(mp.count(tmp))
        return mp[tmp];
    cout << "? " << x << " " << y << " " << z << endl;
    int h;
    cin >> h;
    assert(q-- != 0);
    if(h == -1)
        exit(0);
    return mp[tmp] = h;
}
void guess(int x, int y = 1, int z = 1)
{
    cout << "! " << x << " " << y << " " << z << endl;
}
int is(int x, int y)
{
    int cur = ask(x, y);
    random_shuffle(dd, dd + 4);
    for(int d = 0;d < 4;d++)
    {
        int nwx = x + dd[d].fi, nwy = y + dd[d].se;
        if(ask(nwx, nwy) > cur)
            return d;
    }
    return -1;
}
int main()
{
    fio
//    ifstream cin("in.in");
    srand(rng());
    cin >> n >> m >> k >> q;
    if(max(m, k) == 1)
    {
        int l = 1, r = n;
        while(l < r)
        {
            int mid = (l + r) / 2;
            int vm = ask(mid), vm1 = ask(mid + 1);
            if(vm < vm1)
                l = mid + 1;
            else
                r = mid;
        }
        guess(l);
    }
    else if(k == 1)
    {
        int x = rng() % n + 1, y = rng() % m + 1;
        while(is(x, y) != -1)
        {
            int t = is(x, y);
            x += dd[t].fi;
            y += dd[t].se;
        }
        guess(x, y);
    }
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |