#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
int p[5010], ax[5010], r[5010], ri[5010], ex[5010];
int n;
void obrni() {
  for (int i = 0, _n = n; i < _n; i++) ri[r[i]] = i;
}
int main() {
  scanf("%d", &n);
  int la = 0;
  for (int i = 0, _n = n; i < _n; i++) {
    printf("? 0 %d\n", i);
    fflush(stdout);
    scanf("%d", ax + i);
    if (ax[i] == 0) la = i;
  }
  p[0] = 0;
  for (int i = 1, _n = n; i < _n; i++) {
    printf("? %d %d\n", i, la);
    fflush(stdout);
    scanf("%d", p + i);
  }
  int res = 0;
  for (int i = 0, _n = n; i < _n; i++) {
    bool legit = 1;
    for (int j = 0, _n = n; j < _n; j++) {
      r[j] = (i ^ p[j]);
      if (r[j] >= n) legit = 0;
    }
    if (!legit) continue;
    obrni();
    for (int j = 0, _n = n; j < _n; j++)
      if ((ri[j] ^ i) != ax[j]) legit = 0;
    if (!legit) continue;
    res++;
    for (int j = 0, _n = n; j < _n; j++) ex[j] = r[j];
  }
  printf("!\n%d\n", res);
  for (int i = 0, _n = n; i < _n; i++)
    printf("%d%c", ex[i], i + 1 == n ? '\n' : ' ');
  return 0;
}
