#include <bits/stdc++.h>
using namespace std;
const int max_N = 5e3 + 10;
int pxb[max_N][max_N];
int used[max_N];
int p[max_N], b[max_N];
int ask(int i, int j);
int valid(int x);
int N;
int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) {
    pxb[0][i] = ask(0, i);
  }
  for (int i = 0; i < N; ++i) {
    pxb[i][0] = ask(i, 0);
  }
  for (int i = 1; i < N; ++i) {
    for (int j = 1; j < N; ++j) {
      pxb[i][j] = pxb[0][j] ^ pxb[0][0] ^ pxb[i][0];
    }
  }
  int lv = 0;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    if (valid(i)) {
      lv = i;
      ++cnt;
    }
  }
  valid(lv);
  cout << "!" << endl;
  cout << cnt << endl;
  for (int i = 0; i < N; ++i) {
    cout << p[i] << ' ';
  }
  cout << endl;
}
int ask(int i, int j) {
  cout << "? " << i << ' ' << j << endl;
  int x;
  cin >> x;
  return x;
}
int valid(int x) {
  memset(used, 0, sizeof(used));
  memset(p, -1, sizeof(p));
  memset(b, -1, sizeof(b));
  p[0] = x;
  for (int i = 0; i < N; ++i) {
    b[i] = pxb[0][i] ^ p[0];
    if (b[i] < 0 || b[i] >= N) {
      return 0;
    } else if (used[b[i]]) {
      return 0;
    } else {
      used[b[i]] = 1;
    }
  }
  for (int i = 1; i < N; ++i) {
    p[i] = pxb[i][0] ^ b[0];
  }
  for (int i = 0; i < N; ++i) {
    if (0 <= p[i] && p[i] < N && b[p[i]] == i) {
      continue;
    } else {
      return 0;
    }
  }
  return 1;
}
