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

// #define LOCAL

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int random(int l, int r)
{
    return rng() % (r - l + 1) + l;
}

const int MAXN = 500;
const int MAXK = 500;
const int INF = 1e9;

int n, k;
int Array[MAXN + 5];
int par[MAXN + 5], dist[MAXN + 5];
vector <int> Adj[MAXN + 5];

int Ask(set <int> S)
{
    assert((int)S.size() == k);
    cout << "? ";
    for(auto x : S)
    {
        cout << x << ' ';
    }
    cout << endl;
    int ans = 0;
#ifdef LOCAL
    for(auto x : S)
    {
        if(x <= 0 or x > n)
        {
            cout << "Wa";
            exit(0);
        }
        ans ^= Array[x];
    }
#endif
    cin >> ans;
    return ans;
}

void answer(int res)
{
    cout << "! " << res << endl;
#ifdef LOCAL
    for(int i = 1; i <= n; i++)
    {
        res ^= Array[i];
    }
    if(res == 0)
    {
        cout << "Ok";
    }
    else
    {
        cout << "WA";
    }
#endif
    exit(0);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // freopen("Input.txt", "r", stdin);
    // freopen("Output.txt", "w", stdout);
    cin >> n >> k;
    // for(int i = 1; i <= n; i++)
    // {
    //     Array[i] = random(1, INF);
    // }
    for(int i = 0; i <= n; i++)
    {  
        for(int j = i + 1; j <= n; j++)
        {
            if(j - i > k)
            {
                continue;
            }
            int tmp = k - (j - i);
            if(tmp & 1)
            {
                continue;
            }
            else
            {
                if(n - j < tmp / 2 or i < tmp / 2)
                {
                    continue;
                }
                Adj[i].push_back(j);
                Adj[j].push_back(i);
            }
        }
    }
    queue <int> BFS;
    for(int i = 0; i <= n; i++)
    {
        dist[i] = INF;
        par[i] = 0;
    }
    BFS.push(0);
    dist[0] = 0;
    while(BFS.empty() == false)
    {
        int node = BFS.front();
        BFS.pop();
        for(auto x : Adj[node])
        {
            if(dist[x] > dist[node] + 1)
            {
                dist[x] = dist[node] + 1;
                par[x] = node;
                BFS.push(x);
            }
        }
    }
    if(dist[n] == INF)
    {
        cout << -1;
        return 0;
    }
    vector <int> Path;
    int temp = n;
    Path.push_back(n);
    while(par[temp] != 0)
    {
        Path.push_back(par[temp]);
        temp = par[temp];
    }
    reverse(Path.begin(), Path.end());
    int cursize = 0, res = 0;
    set <int> Cur, Rem;
    for(int i = 1; i <= n; i++)
    {
        Rem.insert(i);
    }
    for(auto x : Path)
    {
        if(x > cursize)
        {
            set <int> tmp;
            set <int> New;
            for(int i = 0; i < x - cursize; i++)
            {
                tmp.insert(*Rem.begin());
                New.insert(*Rem.begin());
                Rem.erase(*Rem.begin());
            }
            for(int i = x - cursize; i < k; i += 2)
            {
                tmp.insert(*Rem.begin());
                New.insert(*Rem.begin());
                Rem.erase(*Rem.begin());
                tmp.insert(*Cur.begin());
                Cur.erase(*Cur.begin());
            }
            res ^= Ask(tmp);
            for(auto x : New)
            {
                Cur.insert(x);
            }
            for(int i = 1; i <= n; i++)
            {
                if(!Cur.count(i))
                {
                    Rem.insert(i);
                }
            }
            cursize = x;
        }
        else
        {
            set <int> tmp;
            set <int> New;
            for(int i = 0; i < cursize - x; i++)
            {
                tmp.insert(*Cur.begin());
                Cur.erase(*Cur.begin());
            }
            for(int i = cursize - x; i < k; i += 2)
            {
                tmp.insert(*Rem.begin());
                New.insert(*Rem.begin());
                Rem.erase(*Rem.begin());
                tmp.insert(*Cur.begin());
                Cur.erase(*Cur.begin());
            }
            res ^= Ask(tmp);
            for(auto x : New)
            {
                Cur.insert(x);
            }
            for(int i = 1; i <= n; i++)
            {
                if(!Cur.count(i))
                {
                    Rem.insert(i);
                }
            }
            cursize = x;
        }
    }
    answer(res);
}