#include <bits/stdc++.h>
int query(int i, int j) {
  std::cout << "? " << i << " " << j << std::endl;
  int result;
  std::cin >> result;
  return result;
}
void fill(int pxor[], int bxor[], int n) {
  for (int i = 0; i < n; ++i) {
    pxor[i] = query(i, 0);
    bxor[i] = query(0, i);
  }
}
int main() {
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  int n, pxor[5010], bxor[5010], ans[5010];
  std::cin >> n;
  fill(pxor, bxor, n);
  bool ok[5010] = {0};
  int stabilize = pxor[0] ^ bxor[0], count = 0;
  for (int value = 0; value < n; ++value) {
    bool isValueGood = true;
    int p[5010], b[5010];
    p[0] = value;
    for (int i = 1; i < n; ++i) {
      p[i] = value ^ pxor[0] ^ pxor[i];
    }
    b[p[0]] = 0;
    for (int i = 0; i < n; ++i) {
      if (i != p[0]) {
        b[i] = 0 ^ bxor[p[0]] ^ bxor[i];
      }
    }
    if ((p[0] ^ b[0]) != bxor[0]) continue;
    for (int i = 0; i < n; ++i) {
      if (b[p[i]] != i || p[i] >= n) isValueGood = false;
    }
    if (!isValueGood) continue;
    ++count;
    for (int i = 0; i < n; ++i) ans[i] = p[i];
  }
  std::cout << "!" << std::endl;
  std::cout << count << std::endl;
  if (count > 0) {
    for (int i = 0; i < n; ++i) std::cout << ans[i] << " ";
  }
}
