#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * f;
}
int n, b[5010], p[5010], a[5010], bb[5010], ans = 0, res[5010];
bool check(int x) {
  a[0] = x;
  for (int i = 1; i < n; ++i)
    if ((a[i] = p[i] ^ a[0]) >= n) return 0;
  for (int i = 0; i < n; ++i) bb[a[i]] = i;
  for (int i = 0; i < n; ++i)
    if ((bb[i] ^ a[0]) != b[i]) return 0;
  return 1;
}
int main() {
  n = read();
  for (int i = 0; i < n; ++i) {
    printf("? 0 %d\n", i);
    fflush(stdout);
    b[i] = read();
  }
  for (int i = 1; i < n; ++i) {
    printf("? %d 0\n", i);
    fflush(stdout);
    p[i] = read() ^ b[0];
  }
  for (int i = 0; i < n; ++i)
    if (check(i))
      if (++ans == 1)
        for (int j = 0; j < n; ++j) res[j] = a[j];
  printf("!\n%d\n", ans);
  for (int i = 0; i < n; ++i) printf("%d ", res[i]);
  return 0;
}
