#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int INF = (1 << 30) - 1;
const int mod = (int)(1e9 + 7);
int n;
int V[5010];
int VB[5010];
int A[5010];
int ans[5010];
int main() {
  scanf("%d", &n);
  int p;
  for (int i = 0; i < n; ++i) {
    printf("? 0 %d\n", i);
    fflush(stdout);
    scanf("%d", &V[i]);
    if (V[i] == 0) p = i;
  }
  for (int i = 1; i < n; ++i) {
    printf("? %d %d\n", i, p);
    fflush(stdout);
    scanf("%d", &VB[i]);
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    bool flag = true;
    for (int j = 0; j < n; ++j) {
      if (V[VB[j] ^ i] != (i ^ j)) {
        flag = false;
        break;
      }
    }
    if (flag) {
      cnt++;
      if (cnt == 1) {
        ans[0] = i;
        for (int j = 1; j < n; ++j) ans[j] = i ^ VB[j];
      }
    }
  }
  printf("!\n");
  printf("%d\n", cnt);
  for (int i = 0; i < n; ++i) {
    printf("%d ", ans[i]);
  }
  puts("");
  fflush(stdout);
  return 0;
}
