#include <bits/stdc++.h>
using namespace std;
int n, a[10010], b[10010], bb[10010], ans[10010], cnt = 0, p[10010];
bool ha[10010];
int main() {
  scanf("%d", &n);
  for (int i = 0; i <= n - 1; i++) {
    printf("? %d %d\n", 0, i);
    fflush(stdout);
    scanf("%d", &a[i]);
  }
  for (int i = 0; i <= n - 1; i++) {
    printf("? %d %d\n", i, 0);
    fflush(stdout);
    scanf("%d", &b[i]);
  }
  for (int i = 0; i <= n - 1; i++) {
    memset(ha, 0, sizeof(ha));
    bool pan = 1;
    bb[0] = i;
    ha[0] = 1;
    p[i] = 0;
    for (int j = 0; j <= n - 1; j++)
      if (i != j) {
        p[j] = bb[0] ^ b[j];
        if (ha[p[j]])
          pan = 0;
        else
          ha[p[j]] = 1;
        bb[p[j]] = j;
      }
    for (int j = 0; j <= n - 1; j++)
      if ((p[0] ^ bb[j]) != a[j]) pan = 0;
    if (pan) {
      cnt++;
      memcpy(ans, p, sizeof(p));
    }
  }
  printf("!\n");
  printf("%d\n", cnt);
  for (int i = 0; i <= n - 1; i++)
    printf("%d%c", ans[i], (i == n) ? '\n' : ' ');
  return 0;
}
