#include <bits/stdc++.h>
using namespace std;
const int maxn = 5000 + 5;
int p[maxn], bp[maxn], a[maxn], b[maxn], c[maxn];
bool used[maxn];
int get_bp(int i, int j) { return p[i] ^ bp[i] ^ p[j]; }
int get_p(int i, int j) { return get_bp(i, j) ^ bp[j]; }
bool check(int pos, int n) {
  memset(used, 0, sizeof(used));
  a[pos] = 0;
  b[0] = pos;
  used[0] = true;
  for (int i = pos - 1; i >= 0; --i) {
    a[i] = a[i + 1] ^ get_p(i, i + 1);
    if (a[i] >= n || used[a[i]]) return false;
    b[a[i]] = i;
  }
  for (int i = pos + 1; i < n; ++i) {
    a[i] = a[i - 1] ^ get_p(i, i - 1);
    if (a[i] >= n || used[a[i]]) return false;
    b[a[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    if ((a[0] ^ b[i]) != p[i] || (a[i] ^ b[i]) != bp[i]) return false;
  }
  memcpy(c, a, sizeof(c));
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    printf("? 0 %d\n", i);
    fflush(stdout);
    scanf("%d", &p[i]);
    printf("? %d %d\n", i, i);
    fflush(stdout);
    scanf("%d", &bp[i]);
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i)
    if (check(i, n)) ++cnt;
  printf("!\n");
  fflush(stdout);
  printf("%d\n", cnt);
  fflush(stdout);
  for (int i = 0; i < n; ++i) printf("%d%c", c[i], " \n"[i == n - 1]);
  fflush(stdout);
  return 0;
}
