#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print_array(T* arr, int num) {
  for (int(i) = (0); (i) < (num); (i)++) cout << arr[i] << ' ';
  cout << '\n';
}
template <typename T>
void print_vector(vector<T> vec) {
  for (int(i) = (0); (i) < (vec.size()); (i)++) cout << vec[i] << ' ';
  cout << '\n';
}
void setIO() {}
int n, x, p0[5010], b0[5010], arr[5010], b[5010], p[5010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  setIO();
  cin >> n;
  for (int(i) = (0); (i) < (n); (i)++) {
    cout << "? " << 0 << " " << i << '\n';
    cout.flush();
    cin >> p0[i];
  }
  for (int(i) = (0); (i) < (n); (i)++) {
    cout << "? " << i << " " << 0 << '\n';
    cout.flush();
    cin >> b0[i];
  }
  int ans = 0;
  bitset<5010> chk;
  for (int(i) = (0); (i) < (n); (i)++) {
    chk.reset();
    int found = 1;
    for (int(j) = (0); (j) < (n); (j)++) {
      p[j] = b0[j] ^ i;
      if (p[j] >= n || chk[p[j]]) {
        found = 0;
        break;
      }
      chk[p[j]] = 1;
    }
    if (!found) continue;
    for (int(j) = (0); (j) < (n); (j)++) b[p[j]] = j;
    for (int(j) = (0); (j) < (n); (j)++) {
      if (p0[j] != (p[0] ^ b[j]) || b0[j] != (p[j] ^ b[0])) {
        found = 0;
        break;
      }
    }
    if (found) {
      ans++;
      if (ans == 1)
        for (int(j) = (0); (j) < (n); (j)++) arr[j] = p[j];
    }
  }
  cout << "!" << '\n' << ans << '\n';
  for (int(i) = (0); (i) < (n); (i)++) cout << arr[i] << " ";
  cout.flush();
}
