#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e18;
const int inf = 1e9;
const int MOD = 1e9 + 7;
const int nax = 5000 + 10;
int n;
int map1[nax][nax];
int b[nax], p[nax], used[8193], res[nax];
bool check() {
  for (int i = 0; i < n; i++)
    if (b[p[i]] != i) return false;
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    cout << '?' << " " << 0 << " " << i << endl;
    fflush(stdout);
    cin >> map1[0][i];
    cout << '?' << " " << i << " " << 0 << endl;
    fflush(stdout);
    cin >> map1[i][0];
  }
  int f = 0;
  for (int first = 0; first < n; first++) {
    int bnot = first;
    int pnot = (map1[0][0] ^ bnot);
    b[0] = bnot;
    p[0] = pnot;
    for (int i = 1; i < n; i++) {
      int bi = (map1[0][i] ^ pnot);
      int pi = (map1[i][0] ^ bnot);
      b[i] = bi, p[i] = pi;
    }
    if (check()) {
      cnt++;
      if (f) continue;
      f = 1;
      for (int i = 0; i < n; i++) res[i] = p[i];
    }
  }
  cout << '!' << endl;
  cout << cnt << endl;
  for (int i = 0; i < n; i++) cout << res[i] << " ";
  return 0;
}
