#include <bits/stdc++.h>
const int md = 1e9 + 7;
const long long hs = 199;
using namespace std;
int ask(int i, int j) {
  cout << "? " << i << " " << j << '\n';
  fflush(stdout), cout.flush();
  int temp;
  cin >> temp;
  return temp;
}
int cnt = 0, at = 0, n;
vector<int> a, b, c, d;
bool check() {
  for (int i = 0; i < n; i++)
    if (c[i] >= n || d[i] >= n || c[d[i]] != i) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  c.resize(n), d.resize(n);
  for (int i = 0; i < n; i++) a.push_back(ask(0, i)), b.push_back(ask(i, 0));
  for (int i = 0; i < n; i++) {
    c[0] = i;
    for (int j = 0; j < n; j++) d[j] = c[0] ^ a[j], c[j] = d[0] ^ b[j];
    if (check()) cnt++, at = i;
  }
  cout << '!' << '\n';
  cout << cnt << '\n';
  c[0] = at;
  for (int i = 0; i < n; i++) d[i] = c[0] ^ a[i], c[i] = d[0] ^ b[i];
  for (auto &i : c) cout << i << " ";
  cout << '\n';
}
