#include <bits/stdc++.h>
using namespace std;
int read() {
  int w = 0, f = 1;
  char c = ' ';
  while (c < '0' || c > '9') f = (c == '-' ? -f : f), c = getchar();
  while (c >= '0' && c <= '9') w = w * 10 + c - '0', c = getchar();
  return w * f;
}
int n, a[5005], b[5005], c[5005], d[5005], t[5005], ans, p[5005], vis[5005];
int ask(int x, int y) {
  printf("? %d %d\n", x, y);
  fflush(stdout);
  return read();
}
signed main() {
  n = read();
  for (int i = 0; i < n; i++) a[i] = ask(i, i), b[i] = ask((i + 1) % n, i);
  for (int i = 0; i < n; i++) c[i] = a[i] ^ b[i], d[i] = a[(i + 1) % n] ^ b[i];
  for (int i = 0; i < n; i++) {
    t[0] = i;
    for (int j = 1; j < n; j++) t[j] = t[j - 1] ^ c[j - 1];
    t[0] = t[n - 1] ^ c[n - 1];
    if (t[0] != i) continue;
    bool fl = 1;
    for (int j = 0; j < n && fl; j++)
      if (t[j] >= n) fl = 0;
    memset(vis, -1, sizeof(int) * n);
    for (int j = 0; j < n && fl; j++) {
      if (vis[t[j]] != -1) fl = 0;
      vis[t[j]] = j;
    }
    for (int j = 0; j < n && fl; j++)
      if (((vis[j] ^ vis[(j + 1) % n]) != d[j]) || ((t[j] ^ vis[j]) != a[j]) ||
          ((t[(j + 1) % n] ^ vis[j]) != b[j]))
        fl = 0;
    if (!fl) continue;
    if (!ans) {
      for (int j = 0; j < n; j++) p[j] = t[j];
    }
    ans++;
  }
  printf("!\n%d\n", ans);
  for (int i = 0; i < n; i++) printf("%d%c", p[i], i == n - 1 ? '\n' : ' ');
  return 0;
}
