#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> p, b, cht, fp;
vector<int> xp, xb;
bool ispermut() {
  vector<int> tp = p;
  sort(tp.begin(), tp.end());
  return (tp == cht);
}
bool check(int fb) {
  b[0] = fb;
  for (int i = 0; i < n; i++) {
    p[i] = xp[i] ^ b[0];
  }
  for (int i = 0; i < n; i++) {
    b[i] = xb[i] ^ p[0];
  }
  if (!ispermut()) {
    return 0;
  }
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    h[p[i]] = i;
  }
  return (h == b);
}
int main() {
  cin >> n;
  p.resize(n), b.resize(n), fp.resize(n);
  xp.resize(n), xb.resize(n);
  cht.resize(n);
  for (int i = 0; i < n; i++) {
    cht[i] = i;
  }
  int xr = 0;
  for (int i = 0; i < n; i++) {
    cout << "? "
         << "0 " << i << endl;
    fflush(stdout);
    cin >> xb[i];
    xr ^= i;
  }
  for (int i = 0; i < n; i++) {
    cout << "? " << i << " 0" << endl;
    fflush(stdout);
    cin >> xp[i];
  }
  if (n & 1) {
    cout << '!' << endl << 1 << endl;
    for (int i = 0; i < n; i++) {
      int val = xr;
      for (int j = 0; j < n; j++) {
        val ^= (xp[i] ^ xb[j] ^ xb[0]);
      }
      cout << val << " ";
    }
    cout << endl;
  } else {
    int ans = 0;
    bool fil = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (check(i)) {
        ans++;
        if (!fil) {
          fp = p;
          fil = 1;
        }
      }
    }
    cout << '!' << endl;
    cout << ans << endl;
    for (int i = 0; i < n; i++) {
      cout << fp[i] << " ";
    }
    cout << endl;
  }
  return 0;
}
