#include <bits/stdc++.h>
using namespace std;
const int N = 5003;
int n, x, y, a[N], b[N], fp[N], _fp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    cout << "? " << i << " " << i << "\n" << flush;
    cin >> x;
    cout << "? " << i + 1 << " " << i << "\n" << flush;
    cin >> y;
    a[i + 1] = a[i] ^ x ^ y;
    b[i] = a[i] ^ x;
  }
  cout << "? " << 0 << " " << n - 1 << "\n" << flush;
  cin >> x;
  b[n - 1] = x;
  for (int i = 0; i < n; ++i) {
    bool k = 1;
    if (b[i] ^ i) k = 0;
    for (int j = 1; j < n; ++j) {
      if ((a[j] ^ i) >= n || ((b[a[j] ^ i] ^ i) ^ j)) {
        k = 0;
        break;
      }
    }
    if (k) {
      ++_fp;
      for (int j = 0; j < n; ++j) {
        fp[j] = a[j] ^ i;
      }
    }
  }
  cout << "!\n" << _fp << "\n";
  for (int i = 0; i < n; ++i) {
    cout << fp[i] << " ";
  }
  cout << flush;
  return 0;
}
