#include <bits/stdc++.h>
using namespace std;
const int N = 5005;
int a[N], b[N], c[N], A[N], B[N];
int main() {
  int n = 0;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    printf("? %d 0\n", i);
    fflush(stdout);
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; ++i) {
    printf("? 0 %d\n", i);
    fflush(stdout);
    scanf("%d", &b[i]);
  }
  int j = 0, m = 0, x = 0;
  for (int i = 0; i < n; ++i) {
    for (j = 0; j < n; ++j) {
      B[j] = b[j] ^ i;
      if (B[j] >= n) {
        break;
      }
      A[B[j]] = j;
    }
    if (j < n) {
      continue;
    }
    for (j = 0; j < n; ++j) {
      if ((A[j] ^ B[0]) != a[j]) {
        break;
      }
    }
    if (j == n) {
      c[++m] = x = i;
    }
  }
  printf("! \n%d\n", m);
  for (int i = 0; i < n; ++i) {
    A[b[i] ^ x] = i;
  }
  for (int i = 0; i < n; ++i) {
    printf("%d ", A[i]);
  }
  return 0;
}
