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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define pb push_back
#define mp make_pair
#define rsz resize
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define f first
#define s second

#define yes	cout << "YES" << '\n'
#define no	cout << "NO" << '\n'
#define finish(x) return void(x)

const int N = 505;
#define inf	0x3f3f3f3f

	
int n, k, dp[N], dq[N],bruh[N];

/*
dp[i][j] = min moves to make i zeros and j ones
*/ 

void solve() {
	cin >> n >> k;
	memset(dp, 0x3f, sizeof(dp));
	dp[n] = 0;
	queue<int> ben;
	ben.push(n);
	while (ben.size()) {
		int x = ben.front(); ben.pop();
		for (int i = 0; i <= min(x,k); ++i) {
			// flip i zeros, (k - i) ones
			// 
			int y = x + (k - i - i);
			if (y >= 0 && y <= n && (n - x) >= (k - i) && dp[y] == inf) {
				dp[y] = dp[x] + 1;
				dq[y] = x, bruh[y] = i;
				ben.push(y);
			}
		}
	}
	if (dp[0] == inf) {
		cout << "-1\n";
		return;
	}
	int x = 0;
	vector<int> a0, a1;
	for (int i = 0; i < n; ++i) a0.push_back(i);
	vector<int> trans;
	while (x != n) {
		int y = dq[x];
		trans.push_back(bruh[x]);
		// cout << y << " -> " << x << endl;
		x = y;
	}
	reverse(all(trans));
	vector<int> t0, t1;
	long long ans = 0;
	for (int x : trans) {
		int zero = x;
		t0.clear(), t1.clear();
		// cout << zero << endl;
		cout << "? ";
		// cout << sz(a0) << ' ' << sz(a1) << " | " << zero << endl;//'\n';
		for (int i = 0; i < (zero); ++i) {
			t0.push_back(a0.back());
			cout << a0.back() +1 << ' ';
			a0.pop_back();
		}
		for (int i = 0; i < k-zero; ++i) {
			t1.push_back(a1.back());
			cout << a1.back() +1 << ' ';
			a1.pop_back();
		}
		cout << endl;
		int tmp; cin >> tmp; ans ^= tmp;
		for (int i : t0) a1.push_back(i);
		for (int i : t1) a0.push_back(i);
	}
	cout << "! " << ans << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);

	int tc = 1;
	// cin >> tc;
	while (tc--)
		solve();
}