#include <bits/stdc++.h>
const int maxn = 5010;
int n;
int bp[maxn + 1], pb[maxn + 1];
int p[maxn + 1], b[maxn + 1];
int result[maxn + 1];
bool zai[maxn + 1];
int cnt;
void init() { scanf("%d", &n); }
void ask() {
  int i;
  for (i = 0; i < n; ++i) {
    printf("? %d %d\n", 0, i);
    fflush(stdout);
    scanf("%d", &pb[i]);
  }
  bp[0] = pb[0];
  for (i = 1; i < n; ++i) {
    printf("? %d %d\n", i, 0);
    fflush(stdout);
    scanf("%d", &bp[i]);
  }
}
bool check() {
  int i;
  for (i = 0; i < n; ++i) zai[i] = false;
  for (i = 0; i < n; ++i) {
    if (p[i] < 0 || p[i] >= n || zai[p[i]]) return false;
    zai[p[i]] = true;
  }
  for (i = 0; i < n; ++i) zai[i] = false;
  for (i = 0; i < n; ++i) {
    if (b[i] < 0 || b[i] >= n || zai[b[i]]) return false;
    zai[b[i]] = true;
  }
  for (i = 0; i < n; ++i) {
    if (p[b[i]] != i) return false;
  }
  return true;
}
void calc_cnt() {
  int t, i, j;
  cnt = 0;
  for (t = 0; t < n; ++t) {
    for (i = 0; i < n; ++i) b[i] = pb[i] ^ t;
    for (i = 0; i < n; ++i) p[i] = bp[i] ^ b[0];
    if (t != p[0]) continue;
    if (check()) {
      ++cnt;
      if (cnt > 0) {
        for (i = 0; i < n; ++i) result[i] = p[i];
      }
    }
  }
}
void work() {
  ask();
  calc_cnt();
}
void output() {
  printf("!\n");
  fflush(stdout);
  printf("%d\n", cnt);
  fflush(stdout);
  for (int i = 0; i < n; ++i) {
    printf("%d", result[i]);
    if (i == n - 1)
      printf("\n");
    else
      printf(" ");
  }
  fflush(stdout);
}
int main() {
  init();
  work();
  output();
  return 0;
}
