#include <bits/stdc++.h>
using namespace std;
int ans[5432][5432], p[5432], b[5432], p_true[5432], b_true[5432];
int main() {
  int n;
  scanf("%d", &n);
  int x;
  for (int i = 0; i < n; i++) {
    printf("? %d %d\n", i, 0);
    fflush(stdout);
    scanf("%d", &x);
    ans[i][0] = x;
  }
  for (int i = 1; i < n; i++) {
    printf("? %d %d\n", 0, i);
    fflush(stdout);
    scanf("%d", &x);
    ;
    ans[0][i] = x;
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    memset(p, -1, sizeof(p));
    memset(b, -1, sizeof(b));
    p[0] = i;
    for (int j = 0; j < n; j++) {
      b[j] = (ans[0][j] ^ p[0]);
    }
    for (int j = 1; j < n; j++) {
      p[j] = (ans[j][0] ^ b[0]);
    }
    int flag = 0;
    for (int j = 0; j < n; j++) {
      if (p[b[j]] != j || p[j] >= n || b[j] >= n) {
        flag = 1;
        break;
      }
    }
    if (!flag) {
      res++;
      for (int j = 0; j < n; j++) {
        p_true[j] = p[j];
        b_true[j] = b[j];
      }
    }
  }
  printf("!\n");
  printf("%d\n", res);
  for (int i = 0; i < n; i++) {
    printf("%d ", p_true[i]);
  }
  printf("\n");
  fflush(stdout);
  return 0;
}
