#include <bits/stdc++.h>
using namespace std;
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
long long inf = 1e18, MOD = 1e9 + 7;
long long n, m, k, ar[1000005], br[1000005];
string s, s1;
vector<int> gen(vector<int> p) {
  vector<int> ret(n);
  for (int i = 0; i < n; i++) {
    ret[p[i]] = i;
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int ti = 1;
  while (ti--) {
    cin >> n;
    vector<int> xor_b0(n), xor_p0(n);
    for (int i = 0; i < n; i++) {
      cout << "? " << 0 << " " << i << endl;
      cin >> xor_p0[i];
      cout << "? " << i << " " << 0 << endl;
      cin >> xor_b0[i];
    }
    vector<int> ans;
    int cnt = 0;
    for (int b0 = 0; b0 < n; b0++) {
      vector<int> p(n);
      for (int i = 0; i < n; i++) {
        p[i] = xor_b0[i] ^ b0;
      }
      vector<int> comp(n), comp2(n);
      comp2 = p;
      sort(comp2.begin(), comp2.end());
      iota(comp.begin(), comp.end(), 0);
      if (comp != comp2) continue;
      vector<int> b = gen(p);
      if (b0 != b[0]) continue;
      bool ok = true;
      for (int i = 0; i < n; i++) {
        if (xor_p0[i] != (p[0] ^ b[i])) ok = false;
      }
      if (!ok) continue;
      cnt++;
      ans = p;
    }
    cout << "!" << endl;
    cout << cnt << endl;
    for (auto i : ans) cout << i << " ";
    cout << endl;
  }
  return 0;
}
