#include <bits/stdc++.h>
using namespace std;
long long modpow(long long a, long long b,
                 long long mod = (long long)(1e9 + 7)) {
  if (!b) return 1;
  a %= mod;
  return modpow(a * a % mod, b / 2, mod) * (b & 1 ? a : 1) % mod;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vector<pair<pair<int, int>, int> > queries;
int interact(int i, int j) {
  cout << "? " << i << " " << j << endl;
  fflush(stdin);
  int x;
  cin >> x;
  queries.push_back(pair<pair<int, int>, int>(pair<int, int>(i, j), x));
  return x;
}
void declare(int n, int arr[], int ways) {
  cout << "!" << endl;
  cout << ways << endl;
  for (int i = 0; i < n; i++) cout << arr[i] << " ";
  cout << endl;
  fflush(stdin);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  while (cin >> n) {
    int xorsum = 0;
    for (int i = 0; i < n; i++) xorsum ^= i;
    int b[n];
    for (int j = 0; j < n; j++) b[j] = interact(0, j);
    int j = 0;
    int ways = 0;
    vector<int> best;
    if (n & 1) {
      int arr_0 = xorsum;
      for (int j = 0; j < n; j++) arr_0 ^= b[j];
      while (j < n && b[j] != arr_0) j++;
      ways = 1;
    } else {
      for (; j < n; j++) {
        int a = b[j];
        bool vis[n];
        memset(vis, false, sizeof(vis));
        for (int i = 0; i < n; i++)
          if ((b[i] ^ a) < n) vis[b[i] ^ a] = true;
        int cnt = 0;
        for (int i = 0; i < n; i++) cnt += vis[i];
        if (cnt == n) best.push_back(j);
      }
      j = best.back();
    }
    int arr[n];
    for (int i = 0; i < n; i++) arr[i] = interact(i, j);
    int ans[n];
    if (n & 1)
      for (int i = 0; i < n; i++) ans[i] = arr[i];
    for (int x : best) {
      int a = b[x];
      int bj = b[j] ^ a;
      bool vis[n];
      memset(vis, false, sizeof(vis));
      int a_p[n], b_p[n];
      for (int i = 0; i < n; i++)
        if ((bj ^ arr[i]) < n) vis[bj ^ arr[i]] = true;
      int cnt = 0;
      for (int i = 0; i < n; i++) cnt += vis[i];
      for (int i = 0; i < n; i++) a_p[i] = bj ^ arr[i];
      for (int i = 0; i < n; i++) b_p[i] = a ^ b[i];
      for (int i = 0; i < n; i++)
        if (a_p[b_p[i]] != i) goto skip;
      for (pair<pair<int, int>, int> pp : queries)
        if ((a_p[pp.first.first] ^ b_p[pp.first.second]) != pp.second)
          goto skip;
      ways += cnt == n;
      if (cnt == n)
        for (int i = 0; i < n; i++) ans[i] = a_p[i];
    skip : {}
    }
    declare(n, ans, ways);
  }
  return 0;
}
