#include <bits/stdc++.h>
using namespace std;
FILE *in, *out;
int N, M, K;
int ar[5100];
int arx[5100];
int p[5100];
int b[5100];
int q(int x, int y) {
  int i;
  cout << "? " << x << " " << y << "\n";
  cout.flush();
  cin >> i;
  return i;
}
int used1[5100];
int used2[5100];
int ANS[5100];
int check() {
  int i, j, k;
  for (i = 0; i < N; i++) {
    if (p[i] >= N || b[i] >= N) return 0;
    used1[i] = 0;
    used2[i] = 0;
  }
  for (i = 0; i < N; i++) {
    used1[p[i]]++;
    if (used1[p[i]] > 1) return 0;
    used2[b[i]]++;
    if (used2[b[i]] > 1) return 0;
    if (i != p[b[i]]) return 0;
  }
  for (i = 0; i < N; i++) {
    ANS[i] = p[i];
  }
  return 1;
}
int DEBUG() {
  int i, j, k;
  for (i = 0; i < N; i++) {
    cout << p[i] << " ";
  }
  cout << "\n";
  for (i = 0; i < N; i++) {
    cout << b[i] << " ";
  }
  cout << "\n";
  return 0;
}
int read() {
  int i, j, k;
  int x, y;
  cin >> N;
  for (i = 0; i < N; i++) ar[i] = q(0, i);
  for (i = 0; i < N; i++) arx[i] = q(i, 0);
  int ans = 0;
  for (i = 0; i < N; i++) {
    p[0] = i;
    for (j = 0; j < N; j++) b[j] = (p[0] ^ ar[j]);
    for (j = 0; j < N; j++) p[j] = (b[0] ^ arx[j]);
    if (check()) ans++;
  }
  cout << "!\n";
  cout << ans << "\n";
  for (i = 0; i < N; i++) {
    cout << ANS[i] << " ";
  }
  cout << "\n";
  cout.flush();
  return 0;
}
int main() {
  read();
  return 0;
}
