#include <bits/stdc++.h>
using namespace std;
const int maxn = 6e3 + 5;
int n;
inline int get(int i, int j) {
  cout << "? " << i << ' ' << j << endl;
  int res;
  cin >> res;
  return res;
}
int a[maxn], b[maxn], x[maxn], p[maxn], ans[maxn], cnt;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) {
    a[i] = get(0, i);
  }
  for (int i = 0; i < n; i++) {
    x[i] = get(i, 0);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) b[j] = (i ^ a[j]);
    for (int j = 0; j < n; j++) p[j] = (b[0] ^ x[j]);
    bool good = 1;
    for (int j = 0; j < n; j++)
      if (b[j] > n || p[b[j]] != j) {
        good = 0;
        break;
      }
    if (good) {
      if (!cnt) {
        for (int j = 0; j < n; j++) ans[j] = p[j];
      }
      cnt++;
    }
  }
  cout << "!\n" << cnt << '\n';
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
  return 0;
}
