#include <bits/stdc++.h>
using namespace std;
const size_t MAX_N = 5000 + 5;
int ans[MAX_N][2], n, p[MAX_N], b[MAX_N], res[MAX_N];
bool known[2][MAX_N];
queue<int> que;
inline void ask(int i, int j) {
  printf("? %d %d\n", i, j);
  fflush(stdout);
  scanf("%d", &ans[i][j != i]);
  if (!(~ans[i][j - i])) exit(0);
}
inline void do_p(bool& ok, int i, int val) {
  if (i >= n) return ok = false, void();
  if (known[0][i]) {
    if (p[i] != val) ok = false;
    return;
  }
  known[0][i] = true;
  que.push(i);
  p[i] = val;
}
inline void do_b(bool& ok, int i, int val) {
  if (known[1][i]) {
    if (b[i] != val) ok = false;
    return;
  }
  known[1][i] = true;
  do_p(ok, b[i] = val, i);
}
int main() {
  int cnt = 0;
  bool ok;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) ask(i, i);
  for (int i = 0; i < n; i++) ask(i, (i + 1) % n);
  for (int i = 0, j; (ok = i < n); i++) {
    memset(known, 0, sizeof known);
    do_b(ok, 0, i);
    while (!que.empty() && ok) {
      j = que.front();
      que.pop();
      do_b(ok, j, p[j] ^ ans[j][0]);
      do_b(ok, (j + 1) % n, p[j] ^ ans[j][1]);
    }
    queue<int>().swap(que);
    if (ok && !(cnt++))
      for (j = 0; j < n; j++) res[j] = p[j];
  }
  printf("! %d\n", cnt);
  for (int j = 0; j < n; j++) printf("%d ", res[j]);
  fflush(stdout);
  return 0;
}
