#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void umin(T &a, T b) {
  a = min(a, b);
}
template <class T>
inline void umax(T &a, T b) {
  a = max(a, b);
}
const int INF = 0x3f3f3f3f;
long long mod = 1e9 + 7;
const int N = 5005;
int a[N], b[N];
int c[N], d[N];
int vis[N], e[N];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    printf("? 0 %d\n", i);
    fflush(stdout);
    scanf("%d", &c[i]);
  }
  for (int i = 0; i < n; i++) {
    printf("? %d 0\n", i);
    fflush(stdout);
    scanf("%d", &d[i]);
  }
  puts("!");
  int ans = 0;
  for (int i = 0; i < n; i++) {
    memset(vis, 0, sizeof vis);
    vis[i] = 1;
    a[0] = i;
    int ok = 1;
    for (int j = 1; j < n; j++) {
      a[j] = d[j] ^ a[0] ^ d[0];
      if (a[j] < 0 || a[j] >= n) {
        ok = 0;
        break;
      }
      if (vis[a[j]]) {
        ok = 0;
        break;
      }
      vis[a[j]] = 1;
      if ((a[0] ^ j) != c[a[j]]) {
        ok = 0;
        break;
      }
    }
    ans += ok;
    if (ok && ans == 1) {
      for (int j = 0; j < n; j++) {
        e[j] = a[j];
      }
    }
  }
  printf("%d\n", ans);
  for (int i = 0; i < n; i++) {
    printf("%d ", e[i]);
  }
  return 0;
}
