#include <bits/stdc++.h>
using namespace std;
const int maxn = 10005;
int p[maxn], q[maxn], c[maxn], a[maxn], b[maxn];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    printf("? %d %d\n", i, 0);
    fflush(stdout);
    scanf("%d", &a[i]);
    printf("? %d %d\n", 0, i);
    fflush(stdout);
    scanf("%d", &b[i]);
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    p[0] = i;
    int succ = 1;
    for (int j = 0; j < n; ++j) q[j] = p[0] ^ b[j];
    for (int j = 1; j < n; ++j) p[j] = q[0] ^ a[j];
    for (int j = 0; j < n; ++j)
      if (q[p[j]] != j) succ = 0;
    if (succ) {
      for (int j = 0; j < n; ++j) c[j] = p[j];
      ++cnt;
    }
  }
  printf("!\n%d\n", cnt);
  for (int i = 0; i < n; ++i) printf("%d ", c[i]);
  fflush(stdout);
  return 0;
}
