#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979;
const double eps = 1e-15;
const long long _INF = 1e18;
const int INF = 2e9;
const int maxn = 5010;
const int maxm = 100000;
int n, p[maxn], b[maxn], c[maxn], ans[maxn], sum;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    printf("? %d 0\n", i);
    fflush(stdout);
    scanf("%d", &p[i]);
  }
  for (int i = 0; i < n; ++i) {
    printf("? 0 %d\n", i);
    fflush(stdout);
    scanf("%d", &b[i]);
  }
  sum = 0;
  bool isok;
  for (int i = 0; i < n; ++i) {
    if (p[i] != i) continue;
    isok = true;
    for (int j = 0; j < n; ++j) {
      c[j] = p[j] ^ i;
      if (c[j] >= n || (b[c[j]] ^ c[0]) != j) {
        isok = false;
        break;
      }
    }
    if (isok) {
      ++sum;
      for (int j = 0; j < n; ++j) ans[j] = c[j];
    }
  }
  printf("!\n%d\n", sum);
  printf("%d", ans[0]);
  for (int i = 1; i < n; ++i) printf(" %d", ans[i]);
  puts("");
  fflush(stdout);
  return 0;
}
