#include <bits/stdc++.h>
using namespace std;
const int N = 5e3 + 3, NUM = 10, BIG = 1e9 + 3, MOD = 1e9 + 7, P = 20, K = 30;
const double EPS = 1e-6, PI = 3.14159265359;
int n, c[N], c2[N], ans_size;
vector<int> ans;
void check(int p0) {
  vector<int> p(n), b(n);
  p[0] = p0;
  for (int i = 0; i < n; ++i) b[i] = (p[0] ^ c[i]);
  for (int i = 1; i < n; ++i) p[i] = (b[0] ^ c2[i]);
  if ((p[0] ^ b[0]) != c2[0]) return;
  if ((p[0] ^ b[0]) != c[0]) return;
  for (int i = 0; i < n; ++i)
    if (b[i] < n && p[b[i]] != i) return;
  vector<int> num1(n), num2(n);
  for (int i = 0; i < n; ++i) {
    if (p[i] >= n || p[i] >= n) return;
    num1[p[i]]++;
    num2[b[i]]++;
  }
  for (int i = 0; i < n; ++i)
    if (num1[i] != 1 || num2[i] != 1) return;
  ans = p;
  ans_size++;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  int k;
  for (int i = 0; i < n; ++i) {
    cout << "? 0 " << i << endl;
    cin >> c[i];
    if (c2[i] == -1) exit(0);
  }
  for (int i = 0; i < n; ++i) {
    cout << "? " << i << " 0" << endl;
    cin >> c2[i];
    if (c2[i] == -1) exit(0);
  }
  for (int i = 0; i < n; ++i) check(i);
  cout << "!" << endl;
  cout << ans_size << endl;
  if (ans_size == 0) return 0;
  for (int i = 0; i < ans.size(); ++i) cout << ans[i] << " ";
  cout << endl;
  return 0;
}
