#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct op {
  int x, y, re;
} ops[10004];
int ar[5005];
int iar[5005];
bool chk(int n) {
  for (int i = (0); i < (n); i++) iar[ar[i]] = i;
  for (int i = (0); i < (2 * n); i++)
    if ((ar[ops[i].x] ^ iar[ops[i].y]) != ops[i].re) return 0;
  return 1;
}
void gen(int n, int a0) {
  ar[0] = a0;
  for (int i = (1); i < ((n - 1) + 1); i++) ar[i] = ops[0].re ^ ops[i].re ^ a0;
}
bool debug = 0;
int targar[5005], targiar[5005];
int cx = 0;
int ask(int i, int j) {
  cout << "? " << i << ' ' << j << endl;
  int re;
  if (debug)
    re = targar[i] ^ targiar[j];
  else
    cin >> re;
  ops[cx++] = {i, j, re};
  return re;
}
signed main() {
  int n;
  cin >> n;
  if (debug) {
    for (int i = (0); i < (n); i++) cin >> targar[i];
    for (int i = (0); i < (n); i++) targiar[targar[i]] = i;
  }
  for (int i = (0); i < (n); i++) ask(i, 0);
  for (int i = (0); i < (n); i++) ask(0, i);
  int L = 0, a = 0;
  for (int i = (0); i < (n); i++) {
    gen(n, i);
    if (chk(n)) {
      L = i;
      a++;
    }
  }
  cout << "!" << endl;
  cout << a << endl;
  gen(n, L);
  for (int i = (0); i < (n); i++) {
    cout << ar[i];
    if (i != n - 1) cout << ' ';
  }
  cout << endl;
}
