#include using namespace std; #define rep(i, a, b) for(int i = a; i < (b); ++i) #define all(x) begin(x), end(x) #define sz(x) (int)(x).size() typedef long long ll; typedef pair pii; typedef vector vi; #define pb push_back #define mp make_pair // a > b ? bool query(int a, int b) { cout << "? " << a << ' ' << b << endl; int x; cin >> x; if (x == a) return true; else return false; } int main() { cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit); int n, k; cin >> n >> k; vi perm(n); rep(i, 0, n) perm[i] = i+1; random_shuffle(all(perm)); vi specialk(k); rep(i, 0, k) specialk[i] = perm[i]; // find reps, n queries rep(i, k, n) { int ind = i % k; if (query(perm[i], specialk[ind])) specialk[ind] = perm[i]; } // find lowest among reps, k queries int lowest = specialk[0]; rep(i, 1, k) { if (query(lowest, specialk[i])) lowest = specialk[i]; } // n queries vi biggerthanlow; rep(i, 1, n+1) { if (i == lowest) biggerthanlow.pb(i); else if (query(i, lowest)) biggerthanlow.pb(i); } set out; // hoepfully biggerthanlow is small, spend k*biggerthanlow queries while (sz(out) < k) { int cand = -1; for (int x : biggerthanlow) { if (out.count(x)) continue; if (cand == -1) { cand = x; } else if (query(x, cand)) { cand = x; } } out.insert(cand); } cout << "! "; for (int x : out) cout << x << ' '; cout << endl; }