#include <bits/stdc++.h>
using namespace std;
int n, ansc = 0, ansp0;
int p[5005], b[5005];
int query(int i, int j) {
  int t;
  printf("? %d %d\n", i, j);
  fflush(stdout);
  scanf("%d", &t);
  if (t == -1) {
    exit(0);
  }
  return t;
}
bool check(int v) {
  int pp[5005], bb[5005];
  bool cp[5005], cb[5005];
  for (int i = 0; i < n; i++) {
    pp[i] = p[i] ^ v;
    bb[i] = b[i] ^ v;
    cp[i] = false;
    cb[i] = false;
    if (pp[i] >= n || bb[i] >= n) {
      return false;
    }
  }
  for (int i = 0; i < n; i++) {
    if (cp[pp[i]]) {
      return false;
    }
    if (cb[bb[i]]) {
      return false;
    }
    cp[pp[i]] = true;
    cb[bb[i]] = true;
  }
  for (int i = 0; i < n; i++) {
    if (pp[bb[i]] != i) {
      return false;
    }
  }
  return true;
}
int main() {
  scanf("%d", &n);
  p[0] = 0;
  b[0] = query(0, 0);
  for (int i = 1; i < n; i++) {
    p[i] = b[0] ^ query(i, 0);
    b[i] = p[0] ^ query(0, i);
  }
  for (int v = 0; v < n; v++) {
    if (check(v)) {
      ansc++;
      ansp0 = v;
    }
  }
  printf("!\n");
  printf("%d\n", ansc);
  for (int i = 0; i < n; i++) {
    printf("%d ", p[i] ^ ansp0);
  }
  printf("\n");
  return 0;
}
