#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 5007;
int n;
int a[MAXN], b[MAXN];
int p[MAXN], q[MAXN];
bool hp[MAXN], hq[MAXN];
int ans[MAXN];
void init();
void input();
void work();
int query(int x, int y) {
  printf("? %d %d\n", x, y);
  fflush(stdout);
  int res;
  scanf("%d", &res);
  if (res == -1) exit(0);
  return res;
}
bool check(int q0);
int main() {
  init();
  input();
  work();
}
void init() { ios::sync_with_stdio(false); }
void input() { scanf("%d", &n); }
void work() {
  for (int i = 0; i < n; ++i) a[i] = query(i, 0), b[i] = query(0, i);
  int cc = 0;
  for (int i = 0; i < n; ++i) {
    if (check(i)) {
      ++cc;
      if (cc == 1)
        for (int i = 0; i < n; ++i) ans[i] = p[i];
    }
  }
  printf("!\n");
  printf("%d\n", cc);
  for (int i = 0; i < n; ++i) printf("%d ", ans[i]);
  putchar('\n');
}
bool check(int q0) {
  for (int i = 0; i < n; ++i) p[i] = a[i] ^ q0;
  int p0 = p[0];
  for (int i = 0; i < n; ++i) q[i] = b[i] ^ p0;
  memset(hp, false, sizeof(hp));
  memset(hq, false, sizeof(hq));
  for (int i = 0; i < n; ++i) {
    if (p[i] < n && !hp[p[i]])
      hp[p[i]] = true;
    else
      return false;
    if (q[i] < n && !hq[q[i]])
      hq[q[i]] = true;
    else
      return false;
  }
  for (int i = 0; i < n; ++i)
    if (p[q[i]] ^ i) return false;
  return true;
}
