#include <bits/stdc++.h>
using namespace std;
const bool print = false;
const int MAXN = 5111;
int p[MAXN];
int b[MAXN];
int zl[MAXN];
int per[MAXN];
int rp[MAXN];
int perans[MAXN];
int main() {
  int n;
  cin >> n;
  for (int i = (0); i <= (n - 1); i++) {
    cout << "? " << i << " 0\n" << flush;
    cin >> p[i];
  }
  b[0] = p[0];
  for (int i = (1); i <= (n - 1); i++) {
    cout << "? 0 " << i << "\n" << flush;
    cin >> b[i];
  }
  int ans = 0;
  for (int i = (0); i <= (n - 1); i++) {
    for (int j = (0); j <= (n - 1); j++) zl[j] = per[j] = rp[j] = 0;
    per[0] = i;
    rp[i] = 0;
    for (int j = (1); j <= (n - 1); j++) {
      int val = (p[j] ^ p[0] ^ per[0]);
      per[j] = val;
      rp[val] = j;
    }
    bool okej = true;
    for (int j = (0); j <= (n - 1); j++) {
      if (rp[per[j]] != j) okej = false;
      if ((per[j] ^ rp[0]) != p[j]) okej = false;
      if ((per[0] ^ rp[j]) != b[j]) okej = false;
      if (!okej) break;
    }
    if (okej) {
      ans++;
      if (ans == 1)
        for (int j = (0); j <= (n - 1); j++) perans[j] = per[j];
    }
  }
  cout << "!\n" << ans << "\n";
  for (int i = (0); i <= (n - 1); i++) cout << perans[i] << " ";
  cout << "\n" << flush;
}
