#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 5000;
int query(int a, int b) {
  do {
    fprintf(stdout, "? %d %d\n", a, b);
    fflush(stdout);
  } while (0);
  scanf("%d", &b);
  return b;
}
bool build(int *pm, int p0, const int *pp, int N) {
  bool bn[MAX_N];
  memset(bn, 0, N);
  pm[0] = p0;
  bn[pm[0]] = 1;
  for (int i = 1; i < N; i++) {
    pm[i] = pm[i - 1] ^ pp[i - 1];
    if (pm[i] >= N) return 0;
    if (bn[pm[i]]) return 0;
    bn[pm[i]] = 1;
  }
  return (pm[N - 1] ^ pm[0]) == pp[N - 1];
}
bool check(const int *p1, int *p2, const int *bb, int N) {
  for (int i = 0; i < N; i++) p2[p1[i]] = i;
  for (int i = 0; i < N; i++)
    if ((p2[i] ^ p2[(i + 1) % N]) != bb[i]) return 0;
  return 1;
}
bool verify(const int *p1, const int *p2, const int *xx, const int *yy, int N) {
  for (int i = 0; i < N; i++) {
    if ((p1[i] ^ p2[i]) != xx[i]) return 0;
    if ((p1[i] ^ p2[(i + 1) % N]) != yy[i]) return 0;
  }
  return 1;
}
int main() {
  int i, N, ac = 0;
  int xx[MAX_N], yy[MAX_N];
  int pp[MAX_N], bb[MAX_N];
  int p1[MAX_N], p2[MAX_N];
  int ap[MAX_N];
  scanf("%d", &N);
  for (i = 0; i < N; i++) xx[i] = query(i, i);
  for (i = 0; i < N; i++) yy[i] = query(i, (i + 1) % N);
  for (i = 0; i < N; i++) pp[i] = yy[i] ^ xx[(i + 1) % N];
  for (i = 0; i < N; i++) bb[i] = xx[i] ^ yy[i];
  for (i = 0; i < N; i++)
    if (build(p1, i, pp, N))
      if (check(p1, p2, bb, N))
        if (verify(p1, p2, xx, yy, N)) {
          ac++;
          memcpy(ap, p1, sizeof(int) * N);
        }
  do {
    fprintf(stdout, "!\n");
    fflush(stdout);
  } while (0);
  do {
    fprintf(stdout, "%d\n", ac);
    fflush(stdout);
  } while (0);
  do {
    fprintf(stdout, "%d", ap[0]);
    fflush(stdout);
  } while (0);
  for (i = 1; i < N; i++) do {
      fprintf(stdout, " %d", ap[i]);
      fflush(stdout);
    } while (0);
  do {
    fprintf(stdout, "\n");
    fflush(stdout);
  } while (0);
  return 0;
}
