#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const double eps = 1e-12;
const int MOD = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 5e3 + 4;
const int maxm = 1e3 + 4;
inline long long rule(long long x) { return (x %= MOD) += x < 0 ? MOD : 0; }
int A[maxn][maxn], n;
int B[maxn][maxn], p[maxn], b[maxn], a[maxn];
int vis[maxn];
int id = -1;
bool check(int num) {
  p[0] = num;
  vis[num] = num;
  b[num] = 0;
  for (int j = 1; j < n; ++j) {
    p[j] = p[0] ^ B[0][j];
    if (p[j] >= n || vis[p[j]] == num) return false;
    vis[p[j]] = num;
    b[p[j]] = j;
  }
  for (int i = 0; i < n; ++i) {
    if ((p[i] ^ b[id]) != A[i][id]) return false;
    if ((p[0] ^ b[i]) != A[0][i]) return false;
  }
  for (int i = 0; i < n; ++i) a[i] = p[i];
  return true;
}
int main() {
  int ik, i, j, k, kase;
  scanf("%d", &n);
  memset(A, -1, sizeof A);
  memset(vis, -1, sizeof(vis));
  for (int i = 0; i < n; ++i) {
    printf("? 0 %d\n", i);
    fflush(stdout);
    scanf("%d", &A[0][i]);
    if (A[0][i] == 0) id = i;
  }
  for (int j = 0; j < n; ++j) {
    printf("? %d %d\n", j, id);
    fflush(stdout);
    scanf("%d", &A[j][id]);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j)
      if (A[i][j] == -1) A[i][j] = A[i][id] ^ A[0][j];
  }
  for (int i = 0; i < 1; ++i) {
    for (int j = 0; j < n; ++j) B[i][j] = A[i][0] ^ A[j][0];
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    cnt += check(i);
  }
  printf("!\n");
  fflush(stdout);
  printf("%d\n", cnt);
  fflush(stdout);
  for (int i = 0; i < n; ++i) printf("%d%c", a[i], " \n"[i == n - 1]);
  fflush(stdout);
  return 0;
}
