#include <bits/stdc++.h>
using namespace std;
int query(int i, int j) {
  cout << "? " << i << " " << j << endl;
  fflush(stdout);
  int x;
  cin >> x;
  return x;
}
int n;
int perm[5001][5001];
int inv[5001][5001];
bool ok[5001];
int r1[5001], r2[5001];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    r1[i] = query(i, 0);
    r2[i] = query(0, i);
    ok[i] = true;
  }
  int lastgood = -1, cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n and ok[i]; j++) {
      perm[i][j] = r1[j] ^ i;
      if (perm[i][j] >= n) {
        ok[i] = false;
        break;
      }
      inv[i][perm[i][j]] = j;
    }
    for (int j = 0; j < n and ok[i]; j++) {
      if ((perm[i][0] ^ inv[i][j]) != r2[j]) {
        ok[i] = false;
      }
    }
    if (ok[i]) {
      cnt++;
      lastgood = i;
    }
  }
  cout << "!" << endl << cnt << endl;
  for (int i = 0; i < n; i++) {
    cout << perm[lastgood][i] << " ";
  }
  return 0;
}
