#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define debug cout<<"here\n" 
#define MOD 1000000007

const int MAXN = 2e5 +15;
using namespace std;



void solve(){	
	int n; cin>>n;
	int k; cin>>k;

	for(int d=0; d<=500; d++){
		if(d*k < n) continue;
		if((d*k-n)%2) continue;
		int F = (d*k - n)/2;
		if(d < (2*((F + n-1)/n)+1)) continue;
		int x = F%n;
		priority_queue<pair<int,int> > pq;
		for(int i=0; i<x; i++) pq.push({2*(F/n)+3,i+1});
		for(int i=x+1; i<=n; i++) pq.push({2*(F/n)+1, i});
		int ans = 0;
		while(d--){
			cout<<"? ";
			vector<pair<int,int> > v;
			for(int i=0; i<k; i++){
				auto pp = pq.top(); pq.pop();
				cout<<pp.ss<<" ";
				v.pb({pp.ff-1,pp.ss});
			}
			cout<<endl;
			for(auto pp : v) pq.push(pp);
			int c; cin>>c; ans ^= c;
		}
		cout<<"! "<<ans;
		return;
	}
	cout<<-1;
}
 
int main(){
	//ios_base::sync_with_stdio(false);
	//cout.tie(0); cin.tie(0);	
	cout<<fixed<<setprecision(12);

	int t =1; //cin>>t;
	for(int i=1; i<= t; i++){
		solve();
		cout<<"\n";
	}
	
	return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/