#include <bits/stdc++.h>
using namespace std;
enum { MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009 };
template <typename T>
ostream &operator<<(ostream &cout, vector<T> &a) {
  for (size_t i = 0; i < a.size(); ++i) cout << a[i] << " ";
  return cout;
}
template <typename T>
ostream &operator<<(ostream &cout, vector<vector<T> > &a) {
  for (size_t i = 0; i < a.size(); ++i) cout << a[i] << endl;
  return cout;
}
int p[5000];
int b[5000];
int p_check[5000];
int b_check[5000];
int32_t main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  int x = 0;
  for (int i = 0; i < n; ++i) {
    cout << "? " << i << " 0" << endl;
    cin >> p[i];
    x ^= p[i];
    x ^= i;
  }
  b[0] = p[0];
  for (int i = 1; i < n; ++i) {
    cout << "? 0 " << i << endl;
    cin >> b[i];
  }
  int ans = 0;
  int x_g = 0;
  bool nice = 1;
  for (int cur = 0; cur < n; ++cur) {
    x = cur;
    for (int i = 0; i < n; ++i) {
      p_check[i] = p[i] ^ x;
      b_check[i] = b[i] ^ p_check[0];
    }
    nice = 1;
    for (int i = 0; i < n; ++i) {
      if (p_check[b_check[i]] != i) {
        nice = 0;
        break;
      }
    }
    if (nice) {
      ++ans;
      x_g = x;
    }
  }
  cout << "!" << endl;
  cout << ans << endl;
  for (int i = 0; i < n; ++i) {
    cout << (p[i] ^ x_g) << " ";
  }
  cout << endl;
  return 0;
}
