#include <bits/stdc++.h>
using namespace std;
int n, a[5005], c[5005], p[5005], b[5005];
int ans;
int an[5005];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cout << "? " << i << " " << 0 << "\n";
    fflush(stdout);
    cin >> a[i];
    cout << "? " << 0 << " " << i << "\n";
    fflush(stdout);
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    int p0 = a[0] ^ i;
    int u = 0;
    for (int j = 0; j < n; j++) {
      p[j] = (a[j] ^ i);
      b[p[j]] = j;
    }
    if (b[0] != i) {
      continue;
    }
    for (int j = 1; j < n; j++) {
      if (b[j] != (c[j] ^ p0)) {
        u = 1;
      }
    }
    if (!u) {
      ans++;
      for (int j = 0; j < n; j++) an[j] = p[j];
    }
  }
  cout << "!\n";
  cout << ans << "\n";
  for (int i = 0; i < n; i++) {
    cout << an[i] << " ";
  }
  fflush(stdout);
}
