#include <bits/stdc++.h>
using namespace std;
int res[5555];
int ask(int i, int j) {
  cout << "? " << i << " " << j << endl;
  int t;
  cin >> t;
  return t;
}
int ap[5555], ab[5555], b[5555], p[5555];
int n;
bool check(int x) {
  for (int i = 0; i < n; i++) p[i] = ap[i] ^ x;
  for (int i = 0; i < n; i++) b[i] = p[0] ^ ab[i];
  for (int i = 0; i < n; i++)
    if (p[b[i]] != i) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; i++) ap[i] = ask(i, 0);
  for (int i = 0; i < n; i++) ab[i] = ask(0, i);
  cout << "!" << endl;
  int res = 0;
  int sb;
  for (int x = 0; x < n; x++)
    if (check(x)) res++, sb = x;
  cout << res << endl;
  for (int i = 0; i < n; i++) p[i] = ap[i] ^ sb;
  for (int i = 0; i < n; i++) cout << p[i] << " ";
  cout << endl;
  return 0;
}
