Перепиши данный код на Java JDK 1.8.0_181        Save New Duplicate & Edit Just Text
#include <bits/stdc++.h>
// tiom4eg's precompiler options
// POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
// IO settings
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0)
// Quick types
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair <int, int>
#define vi vector <int>
#define mi vector <vector <int>>
// Quick functions
//#define endl "\n"
#define F first
#define S second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define pb push_back
#define mp make_pair
// Quick fors
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORS(i, a, b, c) for (int i = a; i < b; i += c)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)
#define EACH(e, a) for (auto& e : a)
// Pragmas
#ifndef TIOM4EG
#pragma GCC optimize("O3,unroll-loops") // let the chaos begin!
#pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt,tune=native")
#pragma GCC comment(linker, "/stack:200000000")
#endif
// PBDS
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>
#define ook order_of_key
#define fbo find_by_order
using namespace __gnu_pbds;
// POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS POGGERS
using namespace std;
mt19937 rng(chrono::duration_cast<chrono::milliseconds>(chrono::system_clock::now().time_since_epoch()).count());
#define int long long
const int INF = 1e9 + 7, INFLL = 1e13 + 7, MD = 998244353, MAX = 1 << 19, MOD = 1e9 + 7, LG = 30, B = 64000000;

signed main() {
    //fastIO;
    int t; cin >> t;
    while (t--) {
        vector <pii> r, b;
        FOR(i, 0, 7) {
            cout << "? 2 " << i + 1 << endl;
            char c; cin >> c;
            (c == 'R' ? r : b).pb({2, i + 1});
        }
        int v = sz(r), w = sz(b);
        FOR(i, 0, 4) {
            cout << "? 1 " << (v > w ? r : b)[i].S << endl;
            char c; cin >> c;
            (c == 'R' ? r : b).pb({1, (v > w ? r : b)[i].S});
            cout << "? 3 " << (v > w ? r : b)[i].S << endl;
            cin >> c;
            (c == 'R' ? r : b).pb({3, (v > w ? r : b)[i].S});
        }
        FOR(i, 0, sz(r)) FOR(j, i + 1, sz(r)) FOR(k, j + 1, sz(r)) FOR(l, k + 1, sz(r)) {
            unordered_map <int, int> x, y;
            ++x[r[i].F], ++y[r[i].S];
            ++x[r[j].F], ++y[r[j].S];
            ++x[r[k].F], ++y[r[k].S];
            ++x[r[l].F], ++y[r[l].S];
            EACH(e, x) if (e.S != 2) goto skipr;
            EACH(e, y) if (e.S != 2) goto skipr;
            cout << "! " << min({r[i].F, r[j].F, r[k].F, r[l].F}) << ' ' << min({r[i].S, r[j].S, r[k].S, r[l].S}) << ' ' << max({r[i].F, r[j].F, r[k].F, r[l].F}) << ' ' << max({r[i].S, r[j].S, r[k].S, r[l].S}) << endl;
            goto pass;
            skipr:;
        }
        FOR(i, 0, sz(b)) FOR(j, i + 1, sz(b)) FOR(k, j + 1, sz(b)) FOR(l, k + 1, sz(b)) {
            unordered_map <int, int> x, y;
            ++x[b[i].F], ++y[b[i].S];
            ++x[b[j].F], ++y[b[j].S];
            ++x[b[k].F], ++y[b[k].S];
            ++x[b[l].F], ++y[b[l].S];
            EACH(e, x) if (e.S != 2) goto skipb;
            EACH(e, y) if (e.S != 2) goto skipb;
            cout << "! " << min({b[i].F, b[j].F, b[k].F, b[l].F}) << ' ' << min({b[i].S, b[j].S, b[k].S, b[l].S}) << ' ' << max({b[i].F, b[j].F, b[k].F, b[l].F}) << ' ' << max({b[i].S, b[j].S, b[k].S, b[l].S}) << endl;
            goto pass;
            skipb:;
        }
        pass: string s; cin >> s;
    }
}