#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int mod = 1e9 + 7;
int a[200010][3], p[10010], c[10010], b[10010], ans;
bool flag[10010];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i <= n - 1; i++) {
    printf("? %d %d\n", i, (i + 1) % n);
    fflush(stdout);
    a[i][0] = read();
    printf("? %d %d\n", (i + 1) % n, (i + 1) % n);
    fflush(stdout);
    a[i][1] = read();
  }
  for (int i = 0; i <= n - 1; i++) {
    p[0] = i;
    for (int j = 1; j <= n - 1; j++)
      p[j] = (p[j - 1] ^ a[j - 1][0] ^ a[j - 1][1]);
    memset(flag, 0, sizeof(flag));
    bool pp = 1;
    for (int j = 0; j <= n - 1; j++)
      if (flag[p[j]] == 1) {
        pp = 0;
        break;
      } else
        flag[p[j]] = 1;
    if (!pp) continue;
    for (int j = 0; j <= n - 1; j++) b[p[j]] = j;
    for (int j = 0; j <= n - 1; j++) {
      int k;
      if (j == n - 1)
        k = 0;
      else
        k = j + 1;
      if (((p[j] ^ b[k]) != a[j][0]) || ((p[k] ^ b[k]) != a[j][1])) {
        pp = 0;
        break;
      }
    }
    if (!pp) continue;
    ans++;
    if (ans == 1) memcpy(c, p, sizeof(c));
  }
  printf("!\n");
  fflush(stdout);
  printf("%d\n", ans);
  fflush(stdout);
  if (ans == 0) return 0;
  for (int i = 0; i <= n - 1; i++) {
    printf("%d ", c[i]);
    fflush(stdout);
  }
  return 0;
}
