#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const long long INFF = 0x3f3f3f3f3f3f3f3fll;
const long long M = 1e9 + 7;
const long long maxn = 1e5 + 7;
const double eps = 0.00000001;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <typename T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
template <typename T>
inline T powMM(T a, T b) {
  T ret = 1;
  for (; b; b >>= 1ll, a = a * a % M)
    if (b & 1) ret = 1ll * ret * a % M;
  return ret;
}
int n, m, ans;
int a[maxn];
int query(int i, int j) {
  fflush(stdout);
  int ret;
  cout << '?' << ' ' << i << ' ' << j << '\n';
  cin >> ret;
  return ret;
}
int qq[maxn], q1[maxn], q2[maxn], q0;
int p[maxn], b[maxn], A[maxn];
bool mark[maxn];
int check(int x) {
  int i;
  b[0] = x;
  for (i = 0; i < n - 1; i++) b[i + 1] = b[i] ^ qq[i];
  for (i = 0; i < n; i++) mark[i] = 0;
  for (i = 0; i < n; i++) p[b[i]] = i;
  for (i = 0; i < n; i++) {
    if (b[i] >= n) return 0;
    if (mark[b[i]]) return 0;
    mark[b[i]] = 1;
  }
  for (i = 0; i < n - 1; i++)
    if ((p[i + 1] ^ b[i]) != q1[i]) return 0;
  for (i = 0; i < n - 1; i++)
    if ((p[i + 1] ^ b[i + 1]) != q2[i]) return 0;
  if ((p[0] ^ b[0]) != q0) return 0;
  return 1;
}
int main() {
  cin >> n;
  int i, j;
  for (i = 0; i < n - 1; i++) {
    q1[i] = query(i + 1, i);
    q2[i] = query(i + 1, i + 1);
    qq[i] = q1[i] ^ q2[i];
  }
  q0 = query(0, 0);
  for (i = 0; i < n; i++)
    if (check(i)) {
      ans++;
      for (j = 0; j < n; j++) A[j] = p[j];
    }
  printf("!\n%d\n", ans);
  for (i = 0; i < n; i++) printf("%d ", A[i]);
}
