#include <bits/stdc++.h>
using namespace std;
int n;
int p[5005];
int x[5005], y[5005];
void init() {
  memset(x, 0, sizeof(x));
  memset(y, 0, sizeof(y));
  memset(p, 0, sizeof(p));
}
int main() {
  while (~scanf("%d", &n)) {
    init();
    for (int i = 0; i < n; ++i) {
      printf("? %d %d\n", 0, i);
      fflush(stdout);
      scanf("%d", &x[i]);
    }
    for (int i = 0; i < n; ++i) {
      printf("? %d %d\n", i, 0);
      fflush(stdout);
      scanf("%d", &y[i]);
    }
    int cnts = 0;
    int ans[5005];
    int b[5005];
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) p[j] = y[j] ^ i;
      for (int j = 1; j < n; ++j) b[j] = x[j] ^ p[0];
      b[0] = i;
      int flag = 0;
      for (int j = 0; j < n; ++j) {
        if (p[b[j]] != j || p[j] >= n || b[j] >= n) {
          flag = 1;
          break;
        }
      }
      if (flag == 0) {
        cnts++;
        for (int j = 0; j < n; ++j) ans[j] = p[j];
      }
    }
    printf("!\n%d\n", cnts);
    for (int i = 0; i < n; ++i) printf("%d ", ans[i]);
    printf("\n");
    fflush(stdout);
  }
}
