#include <bits/stdc++.h>
using namespace std;
long long n;
long long ans[5005];
bool vis[5005];
long long a[5005];
long long b[5005];
long long all;
long long sav[5005];
bool takes[5005];
long long c[5005];
bool isperm(long long d[]) {
  memset(vis, false, sizeof vis);
  for (long long i = 0; i < n; i++) {
    if (d[i] >= n || d[i] < 0) return false;
    if (vis[d[i]] == true) return false;
    vis[d[i]] = true;
  }
  return true;
}
void getinv() {
  for (long long i = 0; i < n; i++) {
    a[b[i]] = i;
  }
}
bool check(long long a0) {
  memset(a, -1, sizeof a);
  memset(b, -1, sizeof b);
  for (long long i = 0; i < n; i++) {
    b[i] = ans[i] ^ a0;
  }
  if (!isperm(b)) return false;
  getinv();
  if (!isperm(a)) return false;
  for (long long i = 0; i < n; i++) {
    if ((a[0] ^ b[i]) != ans[i]) return false;
  }
  for (long long i = 0; i < n; i++) {
    if ((a[i] ^ b[0]) != c[i]) return false;
  }
  for (long long i = 0; i < n; i++) sav[i] = a[i];
  return true;
}
int main() {
  cin >> n;
  for (long long i = 0; i <= n - 1; i++) {
    cout << "? 0 " << i << endl;
    cin >> ans[i];
  }
  for (long long i = 0; i < n; i++) {
    cout << "? " << i << " "
         << "0" << endl;
    cin >> c[i];
  }
  long long ret = 0;
  for (long long last = 0; last < n; last++) {
    if (check(last)) {
      ret++;
    }
  }
  cout << "!" << endl;
  cout << ret << endl;
  for (long long i = 0; i < n; i++) cout << sav[i] << " ";
  cout << endl;
  return 0;
}
