#include <bits/stdc++.h>
using namespace std;
void GO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
const long long INF = 1e9 + 7;
const long long mod = (1e9) + 7;
const int maxn = (int)225;
const long double PI = acos(-1.0);
const long double eps = 0.000000001;
mt19937 rnd(time(0));
void solve() {
  int n;
  cin >> n;
  vector<int> b_0(n);
  vector<int> p_0(n);
  for (int i = 0; i < n; ++i) {
    cout << "? 0 " << i << '\n';
    cin >> p_0[i];
    cout << "? " << i << " 0" << '\n';
    cin >> b_0[i];
  }
  vector<int> ans(n);
  int kol = 0;
  for (int i = 0; i < n; ++i) {
    vector<int> b_ans(n), p_ans(n);
    b_ans[0] = i;
    for (int j = 0; j < n; ++j) p_ans[j] = b_ans[0] ^ b_0[j];
    for (int j = 0; j < n; ++j) b_ans[j] = p_ans[0] ^ p_0[j];
    if (b_ans[0] != i) continue;
    bool f = 1;
    for (int j = 0; j < n; ++j) {
      if (b_ans[j] >= n) {
        f = 0;
        break;
      }
      if (p_ans[b_ans[j]] != j) {
        f = 0;
        break;
      }
    }
    if (f) ans = p_ans, kol++;
  }
  cout << "!\n" << kol << '\n';
  for (auto &i : ans) cout << i << ' ';
}
signed main() {
  int Q = 1;
  while (Q--) {
    solve();
  }
}
