#include <bits/stdc++.h>
using namespace std;
int query(int i, int j) {
  printf("? %d %d\n", i, j);
  fflush(stdout);
  scanf("%d", &i);
  return i;
}
const int N = 5000;
int xor1[N], xor2[N];
int P[N], B[N];
bool solve(const int p0, const int n) {
  memset(P, -1, sizeof P);
  memset(B, -1, sizeof B);
  int b0 = p0 ^ xor1[0];
  for (int i = 0; i < n; i++) {
    P[i] = b0 ^ xor2[i];
    B[i] = p0 ^ xor1[i];
  }
  for (int i = 0; i < n; i++) {
    if (B[i] == -1 || P[B[i]] != i) return false;
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    xor1[i] = query(0, i);
    xor2[i] = query(i, 0);
  }
  int ans = 0, p0 = 0;
  for (int i = 0; i < n; i++) {
    if (solve(i, n)) {
      ans++;
      p0 = i;
    }
  }
  printf("!\n%d\n", ans);
  int b0 = p0 ^ xor1[0];
  for (int i = 0; i < n; i++) {
    int val = b0 ^ xor2[i];
    printf("%d%c", val, i == n - 1 ? '\n' : ' ');
  }
  return 0;
}
