#include <bits/stdc++.h>
using namespace std;
int pb[10001];
int b0b[10001];
int tim = 43;
int occurance[15000];
int tp[15000];
int P[15000];
bool check(int b0, int n) {
  ++tim;
  for (int i = 0; i < n; ++i) {
    int rhs = b0 ^ b0b[i];
    occurance[rhs] = tim;
    tp[rhs] = i;
  }
  for (int i = 0; i < n; ++i) {
    if (occurance[i] != tim) {
      return false;
    }
  }
  for (int i = 0; i < n; ++i) {
    int rhs = tp[i] ^ b0;
    if (rhs != pb[i]) {
      return false;
    }
  }
  for (int i = 0; i < n; ++i) {
    P[i] = tp[i];
  }
  return true;
}
int main() {
  int n;
  cin >> n;
  int j = -1;
  for (int i = 0; i < n; ++i) {
    cout << "? " << i << " " << 0 << endl;
    cin >> pb[i];
    if (pb[i] == 0) {
      j = i;
    }
  }
  assert(j != -1);
  for (int i = 0; i < n; ++i) {
    cout << "? " << j << " " << i << endl;
    cin >> b0b[i];
  }
  int ans = 0;
  for (int b0 = 0; b0 < n; ++b0) {
    if (check(b0, n)) {
      ++ans;
    }
  }
  cout << "!" << endl;
  cout << ans << endl;
  for (int i = 0; i < n; ++i) {
    cout << P[i] << " ";
  }
  cout << endl;
}
