#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
const double PI = acos(-1.0);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> b0(n), p0(n);
  int ans;
  for (int i = 0; i < n; i++) {
    cout << "? "
         << "0 " << i << endl;
    cin >> ans;
    p0[i] = ans;
    cout << "? " << i << " 0" << endl;
    cin >> ans;
    b0[i] = ans;
  }
  int res = 0;
  vector<int> p(n), b(n), check(n);
  int last = 0;
  for (int x = 0; x < n; x++) {
    for (int i = 0; i < n; i++) {
      p[i] = (b0[i] ^ x);
      if (p[i] < n) b[p[i]] = i;
    }
    check = p;
    sort(check.begin(), check.end());
    bool yes = 1;
    for (int i = 0; i < n; i++) {
      if (check[i] != i || ((p[0] ^ b[i]) != p0[i]) ||
          ((b[0] ^ p[i]) != b0[i])) {
        yes = 0;
        break;
      }
    }
    if (yes) {
      res++;
      last = x;
    }
  }
  cout << "!" << endl;
  cout << res << endl;
  for (int i = 0; i < n; i++) {
    cout << (b0[i] ^ last) << " ";
  }
  cout << endl;
  return 0;
}
