#include <bits/stdc++.h>
using namespace std;
const int N = 5010;
int n;
int a[N], b[N], c[N];
bool mark[N];
bool check() {
  memset(mark, false, sizeof mark);
  for (int j = 0; j < n; j++) {
    if (b[j] < n && !mark[b[j]])
      mark[b[j]] = true;
    else
      return false;
  }
  return true;
}
bool check2(vector<int> v) {
  memset(mark, false, sizeof mark);
  for (int j = 0; j < n; j++) {
    if (v[j] < n && !mark[v[j]])
      mark[v[j]] = true;
    else
      return false;
  }
  return true;
}
void chap(int in, int i) {
  for (int j = 0; j < n; j++) cout << b[j] << ' ';
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int ans[N] = {}, cnt = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cout << "? " << 0 << ' ' << i << endl;
    fflush(stdout);
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cout << "? " << i << ' ' << 0 << endl;
    fflush(stdout);
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) b[j] = c[i] ^ c[j];
    if (check()) {
      vector<int> v(n);
      for (int j = 0; j < n; j++) v[b[j]] = j;
      bool flag = true;
      if (check2(v)) {
        for (int j = 0; j < n && flag; j++)
          if ((b[0] ^ v[j]) != a[j]) {
            flag = false;
          }
        for (int j = 0; j < n && flag; j++)
          if ((b[j] ^ v[0]) != c[j]) {
            flag = false;
          }
      }
      if (flag) {
        for (int j = 0; j < n; j++) ans[j] = b[j];
        cnt++;
      }
    }
  }
  cout << "!" << endl;
  cout << cnt << endl;
  for (int i = 0; i < n; i++) cout << ans[i] << ' ';
  cout << endl;
  return 0;
}
