#include <bits/stdc++.h>
using namespace std;
int n, m, tot;
int p[10013];
int b[10013];
int a[10013];
int A[10013];
int t[10013];
int chk(int x) {
  for (int i = 0; i < n; ++i) {
    t[i] = x ^ b[i];
    a[t[i]] = i;
    if ((x ^ i) != p[t[i]]) return 0;
  }
  for (int i = 0; i < n; ++i) A[i] = a[i];
  return 1;
}
int main() {
  int T = 1;
  for (int ci = 1; ci <= T; ++ci) {
    scanf("%d", &n);
    int ptr = -1;
    for (int i = 0; i < n; ++i) {
      printf("? %d %d\n", i, n - 1);
      fflush(stdout);
      scanf("%d", p + i);
      if (p[i] == 0) ptr = i;
    }
    b[n - 1] = 0;
    for (int i = 0; i < n - 1; ++i) {
      printf("? %d %d\n", ptr, i);
      fflush(stdout);
      scanf("%d", b + i);
    }
    printf("!\n");
    fflush(stdout);
    tot = 0;
    for (int i = 0; i < n; ++i) {
      m = chk(i);
      tot += m;
    }
    printf("%d\n", tot);
    for (int i = 0; i < n; ++i) printf("%d%c", A[i], " \n"[i == n - 1]);
  }
  return 0;
}
