#include <bits/stdc++.h>
using namespace std;
long long pwr(long long base, long long p, long long mod = (1000000007LL)) {
  long long ans = 1;
  while (p) {
    if (p & 1) ans = (ans * base) % mod;
    base = (base * base) % mod;
    p /= 2;
  }
  return ans;
}
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int n, qarr[2][5005], P[5005], B[5005], ans[5005];
set<int> distinct_;
int query(int i, int j) {
  cout << "? " << i << " " << j << endl;
  int a;
  cin >> a;
  return a;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) qarr[0][i] = query(0, i);
  for (int i = 0; i < n; i++) qarr[1][i] = query(i, 0);
  int cnt = 0;
  for (int val = 0; val < n; val++) {
    P[0] = val;
    for (int i = 1; i < n; i++) P[i] = val ^ qarr[1][0] ^ qarr[1][i];
    B[P[0]] = 0;
    for (int i = 0; i < n; i++)
      if (i != P[0]) B[i] = 0 ^ qarr[0][P[0]] ^ qarr[0][i];
    distinct_.clear();
    if ((P[0] ^ B[0]) != qarr[0][0]) continue;
    bool bad = false;
    for (int i = 0; i < n; i++)
      if (B[P[i]] != i || P[i] >= n) bad = true;
    if (bad) continue;
    cnt++;
    for (int i = 0; i < n; i++) ans[i] = P[i];
  }
  cout << "!" << endl;
  cout << cnt << endl;
  if (cnt > 0) {
    cout << ans[0];
    fflush(stdout);
    for (int i = 1; i < n; i++) {
      cout << " " << ans[i];
      fflush(stdout);
    }
    cout << endl;
  }
  return 0;
}
