#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int n, x, a[N], b[N], p[N], q[N];
bool bo[N];
inline void cs(int x) {
  p[0] = x;
  for (int i = 0; i < n; ++i) q[i] = p[0] ^ a[i];
  for (int i = 1; i < n; ++i) p[i] = q[0] ^ b[i];
}
inline bool check(int x) {
  cs(x);
  memset(bo, 0, n);
  for (int i = 0; i < n; ++i) {
    if (bo[p[i]]) return 0;
    bo[p[i]] = 1;
  }
  memset(bo, 0, n);
  for (int i = 0; i < n; ++i) {
    if (bo[q[i]]) return 0;
    bo[q[i]] = 1;
  }
  for (int i = 0; i < n; ++i)
    if (p[q[i]] != i) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    printf("? 0 %d\n", i);
    fflush(stdout);
    scanf("%d", &a[i]);
  }
  for (int i = 1; i < n; ++i) {
    printf("? %d 0\n", i);
    fflush(stdout);
    scanf("%d", &b[i]);
  }
  int cnt = 0, t;
  for (int i = 0; i < n; ++i)
    if (check(i)) ++cnt, t = i;
  puts("!");
  printf("%d\n", cnt);
  cs(t);
  for (int i = 0; i < n; ++i) printf("%d ", p[i]);
  fflush(stdout);
  return 0;
}
