#include <bits/stdc++.h>
using namespace std;
int n, ans, ans0;
int cntp[100010], tcntp[100010], p[50010], b[50010], qp0[50010], qb0[50010];
int Query(int i, int j) {
  int t;
  cout << "? " << i << ' ' << j << endl;
  cin >> t;
  return t;
}
int main() {
  ios::sync_with_stdio(false);
  int i, j;
  cin >> n;
  if (n == 1)
    cout << '!' << endl << '1' << endl << '0' << endl;
  else {
    for (i = 0; i < n; ++i) {
      qb0[i] = Query(i, 0);
      qp0[i] = Query(0, i);
      ++cntp[qb0[i]];
    }
    ans = 0;
    for (i = 0; i < n; ++i) {
      memset(tcntp, 0, sizeof(tcntp));
      for (j = 0; j < n; ++j) {
        ++tcntp[i ^ j];
        if (tcntp[i ^ j] > cntp[i ^ j]) break;
      }
      if (j >= n) {
        b[0] = i;
        for (j = 0; j < n; ++j) p[j] = b[0] ^ qb0[j];
        for (j = 1; j < n; ++j) b[j] = p[0] ^ qp0[j];
        for (j = 0; j < n; ++j)
          if (p[b[j]] != j) break;
        if (j >= n) {
          ++ans;
          ans0 = b[0];
        }
      }
    }
    cout << "!" << endl;
    cout << ans << endl;
    b[0] = ans0;
    for (i = 0; i < n; ++i) p[i] = b[0] ^ qb0[i];
    for (i = 0; i < n; ++i) cout << p[i] << ' ';
    cout << endl;
  }
  return 0;
}
