#include <bits/stdc++.h>
using namespace std;
long long readi() {
  long long input = 0;
  char c = ' ';
  while (c < '-') {
    c = getchar();
  }
  bool negative = false;
  if (c == '-') {
    negative = true;
    c = getchar();
  }
  while (c >= '0') {
    input = 10 * input + (c - '0');
    c = getchar();
  }
  if (negative) {
    input = -input;
  }
  return input;
}
void printi(long long output) {
  if (output == 0) {
    putchar('0');
    return;
  }
  if (output < 0) {
    putchar('-');
    output = -output;
  }
  int aout[20];
  int ilen = 0;
  while (output) {
    aout[ilen] = ((output % 10));
    output /= 10;
    ilen++;
  }
  for (int i = ilen - 1; i >= 0; i--) {
    putchar(aout[i] + '0');
  }
  return;
}
string reads() {
  string input = "";
  char c = ' ';
  while (c <= ' ') {
    c = getchar();
  }
  while (c > ' ') {
    input += c;
    c = getchar();
  }
  return input;
}
void prints(string output) {
  for (int i = 0; i < output.length(); i++) {
    putchar(output[i]);
  }
  return;
}
int N;
int val[5010], pos[5010];
int tval[5010], tpos[5010];
int can[5010];
int ans;
int query(int x, int y) {
  int input;
  cout << "? " << x << ' ' << y << '\n';
  fflush(stdout);
  cin >> input;
  if (input == -1) {
    exit(0);
  }
  return input;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  srand(time(NULL));
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin >> N;
  for (int i = 0; i < N; i++) {
    val[i] = query(i, 0);
  }
  for (int i = 0; i < N; i++) {
    pos[i] = query(0, i);
  }
  for (int i = 0; i < N; i++) {
    bool flag = true;
    for (int j = 0; j < N; j++) {
      tval[j] = (i xor val[j]);
      if (tval[j] >= N) {
        flag = false;
      }
    }
    if (!flag) {
      continue;
    }
    for (int j = 0; j < N; j++) {
      tpos[tval[j]] = j;
    }
    for (int j = 0; j < N; j++) {
      if ((tpos[0] xor tval[j]) != val[j]) {
        flag = false;
      }
      if ((tpos[j] xor tval[0]) != pos[j]) {
        flag = false;
      }
    }
    if (!flag) {
      continue;
    }
    if (flag) {
      ans++;
      for (int j = 0; j < N; j++) {
        can[j] = tval[j];
      }
    }
  }
  cout << "! " << ans << '\n' << can[0];
  for (int i = 1; i < N; i++) {
    cout << ' ' << can[i];
  }
  cout << '\n';
  return 0;
}
