//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
#include <bits/stdc++.h>
#include<set>
using namespace std;
#define ll long long
#define endl '\n'
#define pb push_back
#define ff first
#define ss second




#define si(x) int(x.size())
#define sum_all(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())


vector<bool> vis;
ll n, k;
vector<ll> par;

ll ask(vector<ll> &arr)
{

	assert(si(arr) == k);
	cout << "? ";
	for (ll i = 0; i < k; ++i)
	{
		cout << arr[i] << " ";
	}

	cout << endl;
	ll x;
	cin >> x;
	return x;
}
void solve()
{


	cin >> n >> k;
	/*
	we do bfs from 0 to n while mantaining a parent to contruct the path also
	*/
	vis.clear();
	vis.resize(n + 1);
	par.clear();
	par.resize(n + 1);
	queue<pair<ll, ll>> q;
	q.push({ 0,-1 });
	while (!q.empty())
	{

		auto u = q.front().ff;
		auto p = q.front().ss;
		q.pop();
		if (vis[u])continue;
		vis[u] = true;
		par[u] = p;
		for (int j = u + k,c=0; j >= u - k;c++, j -= 2)
		{
			

			if (j > n or j < 0) continue;
			ll uc = k - c;
			if (n - u < uc or u<c) continue; 
			if (vis[j]) continue;
			q.push({ j,u });
		}
	}

	if (vis[n] == false)
	{
		cout << -1 << endl;
		return;
	}


	vector<int> ans;

	int v = n;
	while (true)
	{
		ans.pb(v);
		v = par[v];
		if (v == -1) break;
	}
	reverse(ans.begin(), ans.end());

	set<ll> c, uc;
	for (ll i = 1; i <= n; i++)
	{
		uc.insert(i);
	}
	vector<vector<ll>> res;
	for (ll i = 0; i < si(ans) - 1; i++)
	{
		res.pb({});
		ll a = ans[i];
		ll b = ans[i + 1];
		ll val = b - a;
		val = k - val;
		val /= 2;
		/*
		 send val from c to uc
		 ans k-val from uc to c
		*/
		vector<ll> qc, quc;
		ll cnt = 0;
		while (cnt < val)
		{
			auto x = *(c.begin());
			c.erase(x);
			qc.pb(x);
			res.back().pb(x);
			cnt++;
		}

		cnt = 0;
		while (cnt < k - val)
		{
			auto x = *(uc.begin());
			uc.erase(x);
			quc.pb(x);
			res.back().pb(x);
			cnt++;
		}

		while (!qc.empty())
		{
			auto x = qc.back();
			uc.insert(x);
			qc.pop_back();
		}

		while (!quc.empty())
		{
			auto x = quc.back();
			c.insert(x);
			quc.pop_back();
		}


	}
	ll y = 0;
	for (auto &a : res)
	{
		y ^= ask(a);
	}

	cout << "! " << y << endl;

}


int main()
{

	solve();
	return 0;

}
