#include <bits/stdc++.h>
using namespace std;
int n, p[5001], b[5001], a, p1[5001], b1[5001], r[5001];
int main() {
  cin >> n;
  p[0] = 0;
  for (int i = 0; i < n; i++) {
    cout << "? " << 0 << ' ' << i << endl;
    cin >> a;
    b[i] = a;
  }
  for (int i = 1; i < n; i++) {
    cout << "? " << i << ' ' << 0 << endl;
    cin >> a;
    p[i] = a ^ b[0];
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      p1[j] = p[j] ^ i;
      b1[j] = b[j] ^ i;
    }
    bool ok = 1;
    for (int j = 0; j < n; j++)
      if (p1[j] >= n || b1[p1[j]] != j) {
        ok = 0;
        break;
      }
    ans += ok;
    if (ok)
      for (int i = 0; i < n; i++) r[i] = p1[i];
  }
  cout << "!" << endl << ans << endl;
  for (int i = 0; i < n; i++) cout << r[i] << ' ';
}
