#include <bits/stdc++.h>
using namespace std;
int n, x0[6000], x1[6000], a[6000], b[6000], c[6000];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    fflush(stdout);
    cout << "? " << i << " " << i << endl;
    fflush(stdout);
    cin >> x0[i];
    fflush(stdout);
    cout << "? " << (i + 1) % n << " " << i << endl;
    fflush(stdout);
    cin >> x1[i];
  }
  cout << "!" << endl;
  int cnt = 0;
  for (int x = 0; x < n; x++) {
    a[0] = x;
    for (int i = 0; i < n; i++) {
      b[i] = x0[i] ^ a[i];
      a[i + 1] = b[i] ^ x1[i];
    }
    int flg = 1;
    for (int i = 0; i < n; i++) c[i] = 0;
    for (int i = 0; i < n; i++) c[a[i]] = 1;
    for (int i = 0; i < n; i++)
      if (!c[i]) {
        flg = 0;
        break;
      }
    for (int i = 0; i < n; i++)
      if (b[a[i]] != i) {
        flg = 0;
        break;
      }
    if (flg) cnt++;
  }
  cout << cnt << endl;
  for (int x = 0; x < n; x++) {
    a[0] = x;
    for (int i = 0; i < n; i++) {
      b[i] = x0[i] ^ a[i];
      a[i + 1] = b[i] ^ x1[i];
    }
    int flg = 1;
    for (int i = 0; i < n; i++) c[i] = 0;
    for (int i = 0; i < n; i++) c[a[i]] = 1;
    for (int i = 0; i < n; i++)
      if (!c[i]) {
        flg = 0;
        break;
      }
    for (int i = 0; i < n; i++)
      if (b[a[i]] != i) {
        flg = 0;
        break;
      }
    if (flg) {
      for (int i = 0; i < n; i++) cout << a[i] << " ";
      cout << endl;
    }
  }
}
