#include <bits/stdc++.h>
using namespace std;
void fre() {
  system("clear"), freopen("A.txt", "r", stdin);
  freopen("Ans.txt", "w", stdout);
}
void Fre() { system("clear"), freopen("A.txt", "r", stdin); }
void Run(int x = 0) {}
const int mxn = 1e5 + 10;
int n, p[mxn], b[mxn], a[mxn], bb[mxn], res[mxn];
bool check(int x) {
  a[0] = x;
  for (int i = (long long)(1); i <= (long long)(n - 1); i++)
    if ((a[i] = p[i] ^ a[0]) >= n) return 0;
  for (int i = (long long)(0); i <= (long long)(n - 1); i++) bb[a[i]] = i;
  for (int i = (long long)(0); i <= (long long)(n - 1); i++)
    if (bb[i] != (b[i] ^ a[0])) return 0;
  return 1;
}
int main() {
  Run();
  scanf("%d", &n);
  for (int i = (long long)(0); i <= (long long)(n - 1); i++)
    printf("? 0 %d\n", i), fflush(stdout), scanf("%d", &b[i]);
  for (int i = (long long)(1); i <= (long long)(n - 1); i++)
    printf("? %d 0\n", i), fflush(stdout), scanf("%d", &p[i]),
        p[i] = p[i] ^ b[0];
  int ans = 0;
  for (int i = (long long)(0); i <= (long long)(n - 1); i++) {
    if (check(i)) {
      if (++ans == 1)
        for (int j = (long long)(0); j <= (long long)(n - 1); j++)
          res[j] = a[j];
    }
  }
  printf("!\n%d\n", ans);
  for (int i = (long long)(0); i <= (long long)(n - 1); i++)
    printf("%d ", res[i]);
  printf("\n");
  return 0;
}
