#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
void Max(T &a, U b) {
  if (a < b) a = b;
}
template <class T, class U>
void Min(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void add(T &a, U b) {
  a += b;
  if (a >= 1000000007) a -= 1000000007;
}
template <class T, class U>
int min(T a, U b) {
  return a >= b ? b : a;
}
int ans, first[50010], second[50010], a[50010], b[50010], res[50010], g[10240];
void out(int i, int j) {
  cout << "? " << i << " " << j << "\n";
  cin >> ans;
  fflush(stdout);
}
int main() {
  int i, j, k, ca = 0, n, T, m = 0, K;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    out(i, i);
    b[i] = ans;
    out(i, 0);
    a[i] = ans;
  }
  ans = 0;
  int M = 4096 * 2;
  for (int i = 0; i < n; i++) {
    first[i] = 0;
    for (int j = 0; j < n; j++) g[j] = -1;
    int ok = 1;
    for (int j = 0; j < n; j++) {
      k = a[i] ^ a[j];
      if (k >= n) {
        ok = 0;
        break;
      }
      g[k] = j;
    }
    if (!ok) continue;
    for (int j = 0; j < n; j++) {
      if (g[j] == -1) {
        ok = 0;
        break;
      }
      k = g[j];
      first[k] = j;
    }
    if (!ok) continue;
    for (int j = 0; j < n; j++) second[first[j]] = j;
    for (int j = 0; j < n; j++) {
      if ((first[j] ^ second[j]) != b[j]) {
        ok = 0;
        break;
      }
    }
    if (!ok) continue;
    for (int j = 0; j < n; j++) {
      if ((first[j] ^ second[0]) != a[j]) {
        ok = 0;
        break;
      }
    }
    if (!ok) continue;
    ans++;
    for (int j = 0; j < n; j++) res[j] = first[j];
  }
  printf("!\n%d\n", ans);
  for (int i = 0; i < n; i++) printf("%d ", res[i]);
  puts("");
}
