#include <bits/stdc++.h>
using namespace std;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
  std::fill((T *)array, (T *)(array + N), val);
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> c(n);
  for (int i = 0; i < (int)(n); ++i) {
    cout << "? " << i << " " << 0 << endl;
    cin >> a[i];
    cout << "? " << 0 << " " << i << endl;
    cin >> c[i];
  }
  vector<int> res;
  int cnt = 0;
  for (int X = 0; X < (int)(n); ++X) {
    vector<int> b(n);
    vector<int> inv(n);
    vector<bool> used(n);
    b[0] = X;
    inv[X] = 0;
    used[X] = 1;
    bool flag = 1;
    for (int i = 0; i < (int)(n - 1); ++i) {
      b[i + 1] = (X ^ a[0] ^ a[i + 1]);
      if (b[i + 1] >= n) {
        flag = 0;
        break;
      }
      if (used[b[i + 1]]) {
        flag = 0;
        break;
      }
      used[b[i + 1]] = 1;
      inv[b[i + 1]] = i + 1;
    }
    for (int i = 0; i < (int)(n); ++i) {
      if ((c[i] ^ X) != inv[i]) flag = 0;
    }
    if (flag) {
      if (res.size() == 0) {
        res = b;
      }
      cnt++;
    }
  }
  cout << "!" << endl;
  cout << cnt << endl;
  if (cnt != 0) {
    for (int i = 0; i < (int)(n); ++i) {
      cout << res[i];
      if (i != n - 1) cout << " ";
    }
    cout << endl;
  }
  return 0;
}
