﻿#ifdef _MSC_VER
#include<__msvc_all_public_headers.hpp>
#else
#include <bits/stdc++.h>
#endif


using namespace std;
#pragma warning(disable: 4996)

stringstream err;
void debug() {
	string a;
	while (getline(err, a)) {
		cerr << a << "\n";
	}
}

#define cin(a) for (auto& elem: a) cin >> elem;
#define cout(a) for (auto& elem: a) cout << elem << " ";
#define err(a) for (auto& elem: a) err << elem << " ";
#define cerr(a) { cerr << #a << ": [";  for (int i = 0; i + 1 < a.size(); i++) cerr << a[i] << ", ";  if (!a.empty()) cerr << a[a.size() - 1]; cerr << "]\n"; }
#define print(a) cerr << #a << " = " << a << "\n";

typedef vector<int> vInt;
typedef long long int ll;

namespace std {
	template<> struct hash<pair<int, int>> {
		size_t operator()(const pair<int, int>& a) const {
			size_t p1 = hash<int>()(a.first);
			size_t p2 = hash<int>()(a.second);
			return p1 + (p2 << 1);
		}
	};
}

mt19937 rnd(1231);
const int MAXN = 100000;
const long long int M = 1000000007;

unordered_set<pair<int, int>> edges;

vector<int> asked;
vector<int> answ;
void ask(int v) {
	if (asked[v]) return;
	asked[v] = 1;
	cout << "? " << v + 1 << endl;
	cin(answ);
	for (int i = 0; i < answ.size(); i++) {
		if (answ[i] == 1) {
			edges.insert({ min(i, v), max(i, v) });
		}
	}
}
void printAnsw() {
	cout << "!\n";
	for (auto& e : edges) {
		cout << e.first + 1 << " " << e.second + 1 << "\n";
	}
	cout.flush();
}
int solve(int case_num) {
	int n, k;
	cin >> n >> k;

	vector<int> dist(n + 1, 501); // state <=> cnt odd
	vector<int> pred(n + 1, -1);
	queue<int> bfs;

	dist[0] = 0;
	pred[0] = 0;
	bfs.push(0);

	while (!bfs.empty()) {
		int now = bfs.front();
		bfs.pop();
		int dNow = dist[now];

		for (int addOdd = min(k, n - now); addOdd >= 0; addOdd--) {
			int addEven = k - addOdd;
			if (addEven > now) break;
			int state = now - addEven + addOdd;
			if (dist[state] > dNow + 1) {
				dist[state] = dNow + 1;
				pred[state] = now;
				bfs.push(state);
			}

		}
	}

	if (dist[n] > 500) {
		cout << -1 << endl;
		return 0;
	}

	unordered_set<int> odd;
	unordered_set<int> even;
	for (int i = 1; i <= n; i++) even.insert(i);

	vector<int> order;
	int v = n;
	while (pred[v] != v) {
		order.push_back(v);
		v = pred[v];
	}
	reverse(order.begin(), order.end());

	int answ = 0;
	int now = 0;
	for (int i = 0; i < order.size(); i++) {
		int state = order[i];
		int delta = state - now;
		int cntEven = (delta + k) / 2;
		int cntOdd = k - cntEven;

		cout << "? ";
		//                 id   new
		unordered_set<pair<int, int>> changed;
		for (auto& elem : odd) {
			if (cntOdd <= 0) break;
			cntOdd--;
			changed.insert({ elem, 2 });
		}
		for (auto& elem : even) {
			if (cntEven <= 0) break;
			cntEven--;
			changed.insert({ elem, 1 });
		}
		for (auto& p : changed) {
			if (p.second == 2) odd.erase(p.first);
			else even.erase(p.first);

			if (p.second == 2) even.insert(p.first);
			else odd.insert(p.first);

			cout << p.first << " ";
		}
		cout << endl;
		int a;
		cin >> a;
		answ ^= a;

		now = state;
	}

	cout << "! " << answ << endl;
	return 0;
}

void stresstest() {
	while (true) {

	}
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);

	//stresstest();
	int t = 1;
	//cin >> t;
	for (int i = 1; i <= t; i++) {
		if (solve(i) == -1) break;
	}
	//debug();
	//system("pause");
}