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

int main() {
    int n,k; cin >> n >> k;
    vector<bool> vis(n + 1, false);
    vector<int> par(n + 1);
    
    queue<int> q;
    q.push(0);
    vis[0] = true;
    
    while (!q.empty()) {
        int x = q.front(); q.pop();
        if (x == n) {
            break;
        }
        
        for (int i = 0; i <= min(x, k); i++) {
            if (n - x < k - i) continue;
            int newX = x - i + k - i;
            if (vis[newX]) continue;
            vis[newX] = true;
            q.push(newX);
            par[newX] = x;
        }
    }
    
    if (!vis[n]) {
        cout << -1;
        return 0;
    }
    
    deque<int> order;
    int curr = n;
    while (curr != 0) {
        order.push_front(curr);
        curr = par[curr];
    }
    order.push_front(0);
    
    int ans = 0;
    queue<int> good,bad;
    for (int i = 1; i <= n; i++)
        bad.push(i);
    
    for (int i = 0; i < order.size() - 1; i++) {
        int x = (k + order[i] - order[i + 1]) / 2;
        cout << "? ";
        for (int j = 0; j < x; j++) {
            int temp = good.front(); good.pop();
            bad.push(temp);
            cout << temp << ' ';
        }
        for (int j = 0; j < k - x; j++) {
            int temp = bad.front(); bad.pop();
            good.push(temp);
            cout << temp << ' ';
        }
        cout << endl;
        int val; cin >> val;
        ans ^= val;
    }
    cout << "! " << ans;
}