#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int c[N], b[N], f[N], p[N], g[N];
int n;
int ans = 0;
int ret[N];
int fl;
int query(int x, int y) {
  printf("? %d %d\n", x, y);
  fflush(stdout);
  int ret;
  scanf("%d", &ret);
  return ret;
}
int main() {
  scanf("%d", &n);
  for (int i(0); i <= (n - 2); ++i) {
    f[i] = query(i, i);
    g[i] = query(i, i + 1);
  }
  f[n - 1] = query(n - 1, n - 1);
  fl = 0;
  for (int i(0); i <= (n - 1); ++i) {
    b[0] = i;
    for (int j(0); j <= (n - 1); ++j) {
      p[j] = b[j] ^ f[j];
      b[j + 1] = p[j] ^ g[j];
    }
    bool cc = true;
    for (int j(0); j <= (n - 1); ++j)
      if (p[b[j]] != j) {
        cc = false;
        break;
      }
    if (cc) {
      ++ans;
      if (!fl) {
        memcpy(ret, p, sizeof p);
        fl = 1;
      }
    }
  }
  puts("!");
  printf("%d\n", ans);
  for (int i(0); i <= (n - 2); ++i) printf("%d ", ret[i]);
  printf("%d\n", ret[n - 1]);
  return 0;
}
