#include <bits/stdc++.h>
using namespace std;
const int inv = 1000000000;
const int minv = -inv;
const int max_n = 5000 + 5;
int n;
int p0x[max_n];
int b0x[max_n];
int p[max_n];
int b[max_n];
int res;
int sol[max_n];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    printf("? %d %d\n", 0, i);
    fflush(stdout);
    scanf("%d", &p0x[i]);
  }
  b0x[0] = p0x[0];
  for (int i = 1; i < n; ++i) {
    printf("? %d %d\n", i, 0);
    fflush(stdout);
    scanf("%d", &b0x[i]);
  }
  res = 0;
  for (int a = 0; a < n; ++a) {
    p[0] = a;
    for (int i = 0; i < n; ++i) b[i] = p[0] ^ p0x[i];
    for (int i = 1; i < n; ++i) p[i] = b[0] ^ b0x[i];
    bool valid = true;
    for (int i = 0; i < n; ++i) valid = valid and (p[i] < n and b[i] < n);
    if (not valid) continue;
    for (int i = 0; i < n; ++i)
      valid = valid and (p[b[i]] == i and b[p[i]] == i);
    if (not valid) continue;
    ++res;
    if (res == 1)
      for (int i = 0; i < n; ++i) sol[i] = p[i];
  }
  printf("!\n");
  printf("%d\n", res);
  for (int i = 0; i < n; ++i) printf("%d ", sol[i]);
  printf("\n");
  fflush(stdout);
  return 0;
}
