#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 9;
const int MOD = 1e9 + 7;
const long long LINF = (long long)1e18 + 3;
const int SIZE = 5e3 + 2;
int n;
int ans;
int xorx[SIZE][SIZE], xory[SIZE][SIZE];
int odp1[SIZE], odp2[SIZE];
vector<int> result;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cout << "? " << 0 << " " << i << endl;
    cin >> odp1[i];
  }
  for (int i = 0; i < n; i++) {
    cout << "? " << i << " " << 0 << endl;
    cin >> odp2[i];
  }
  for (int i = 0; i < n; i++) {
    vector<int> perm(n), odwperm(n), licz(n);
    bool ok = true;
    for (int j = 0; j < n; j++) {
      perm[j] = odp2[j] ^ i;
      if (perm[j] >= n) {
        ok = false;
        break;
      }
      licz[perm[j]]++;
      odwperm[perm[j]] = j;
    }
    if (!ok) continue;
    for (int j = 0; j < n; j++) {
      if (licz[i] != 1) ok = false;
      if ((perm[0] ^ odwperm[j]) != odp1[j]) ok = false;
      if ((perm[j] ^ odwperm[0]) != odp2[j]) ok = false;
    }
    if (ok) {
      ans++;
      result = perm;
    }
  }
  cout << "!" << endl;
  cout << ans << endl;
  for (auto it : result) cout << it << " ";
  return 0;
}
