#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5050;
int n;
int x;
int a[MAXN], b[MAXN];
int p[MAXN], pinv[MAXN];
int goodOnes;
int ans[MAXN];
int ask(int i, int j) {
  cout << "? " << i << " " << j << endl;
  int res;
  cin >> res;
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    a[i] = ask(0, i);
    if (a[i] == 0) {
      x = i;
    }
  }
  for (int i = 0; i < n; i++) {
    b[i] = ask(i, x);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      pinv[j] = a[j] ^ i;
    }
    for (int j = 0; j < n; j++) {
      p[j] = pinv[x] ^ b[j];
    }
    bool isGood = true;
    for (int j = 0; j < n; j++) {
      if (!(pinv[p[j]] == j)) {
        isGood = false;
        break;
      }
    }
    if (isGood) {
      goodOnes++;
      for (int j = 0; j < n; j++) {
        ans[j] = p[j];
      }
    }
  }
  cout << "!" << endl;
  cout << goodOnes << endl;
  for (int i = 0; i < n; i++) {
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}
