#include <bits/stdc++.h>
using namespace std;
bool debug = 0;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
string direc = "RDLU";
long long ln, lk, lm;
void etp(bool f = 0) {
  puts(f ? "YES" : "NO");
  exit(0);
}
void addmod(int &x, int y, int mod = 1000000007) {
  assert(y >= 0);
  x += y;
  if (x >= mod) x -= mod;
  assert(x >= 0 && x < mod);
}
void et() {
  puts("-1");
  exit(0);
}
int rd(int i, int j) {
  printf("? %d %d\n", i, j);
  fflush(stdout);
  int x;
  scanf("%d", &x);
  return x;
}
int a[5135], b[5135];
int ans[5135], P[5135], B[5135], cnt, ct[5135];
int lvl;
bool ck(int b0) {
  B[0] = b0;
  lvl++;
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    P[i] = b[i] ^ b0;
    if (P[i] >= n) return 0;
    if (ct[P[i]] == lvl) return 0;
    ct[P[i]] = lvl;
  }
  for (int(i) = 0; (i) < (int)(n); (i)++) B[P[i]] = i;
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    if ((P[0] ^ B[i]) != a[i]) return 0;
    if ((P[i] ^ B[0]) != b[i]) return 0;
  }
  return 1;
}
void fmain(int tid) {
  scanf("%d", &n);
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    a[i] = rd(0, i);
    b[i] = rd(i, 0);
  }
  for (int(i) = 0; (i) < (int)(n); (i)++) {
    bool ok = ck(i);
    if (ok) {
      cnt++;
      if (cnt == 1)
        for (int(j) = 0; (j) < (int)(n); (j)++) ans[j] = P[j];
    }
  }
  printf("!\n%d\n", cnt);
  for (int(i) = 0; (i) < (int)(n); (i)++) printf("%d ", ans[i]);
}
int main() {
  int t = 1;
  for (int(i) = 1; (i) <= (int)(t); (i)++) {
    fmain(i);
  }
  return 0;
}
