#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000;
int query(int i, int j) {
  int x;
  cout << "? " << i << " " << j << endl << flush;
  cin >> x;
  return x;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int ans[MAXN], cnt = 0, n, p[MAXN], b[MAXN], zero[MAXN], same[MAXN], i, j;
  cin >> n;
  if (n == 1) {
    cout << '!' << endl;
    cout << 1 << endl;
    cout << 0 << endl << flush;
    return 0;
  }
  for (i = 0; i < n; i++) zero[i] = query(0, i);
  for (i = 0; i < n; i++) same[i] = query(i, i);
  for (i = 0; i < n; i++) {
    bool ok = true;
    p[0] = i;
    for (j = 0; j < n && ok; j++) {
      b[j] = zero[j] ^ i;
      ok &= (0 <= b[j] && b[j] < n);
    }
    ok &= ((p[0] ^ b[0]) == zero[0]);
    for (j = 0; j < n && ok; j++) p[b[j]] = j;
    ok &= (p[0] == i);
    for (j = 0; j < n && ok; j++) ok &= ((p[j] ^ b[j]) == same[j]);
    if (ok) {
      if (cnt == 0) {
        for (j = 0; j < n; j++) ans[j] = p[j];
      }
      cnt++;
    }
  }
  cout << '!' << endl;
  cout << cnt << endl;
  for (i = 0; i < n; i++) cout << ans[i] << " ";
  cout << flush;
  return 0;
}
