#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline T abs(T t) {
  return t < 0 ? -t : t;
}
const long long modn = 1000000007;
inline long long mod(long long x) { return x % modn; }
const int MAXN = 212345;
int n, m, k;
int x[MAXN];
int id[MAXN];
int adj[2][MAXN];
int s[2][MAXN];
int res;
vector<int> ans;
void go(int v) {
  s[0][0] = v;
  for (int a = 0; a < n; a++) {
    s[1][a] = v ^ x[a];
    s[0][adj[1][a]] = v ^ x[a];
  }
  for (int a = 0; a < n; a++)
    if (s[1][a] >= n || s[0][s[1][a]] != a) return;
  res++;
  if (res == 1) {
    for (int a = 0; a < n; a++) {
      ans.push_back(s[0][a]);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int a = 0; a < n; a++) {
    printf("? 0 %d\n", a);
    fflush(stdout);
    int xo;
    scanf("%d", &xo);
    if (xo == -1) return 0;
    x[a] = xo;
    id[xo] = a;
    if (xo == 0) {
      adj[0][0] = a;
      adj[1][a] = 0;
    }
  }
  for (int a = 1; a < n; a++) {
    printf("? %d %d\n", a, adj[0][0]);
    fflush(stdout);
    int xo;
    cin >> xo;
    if (xo == -1) return 0;
    adj[0][a] = id[xo];
    adj[1][id[xo]] = a;
  }
  for (int a = 0; a < n; a++) go(a);
  puts("!");
  fflush(stdout);
  printf("%d\n", res);
  fflush(stdout);
  for (int u : ans) {
    printf("%d ", u);
  }
  puts("");
  fflush(stdout);
}
