#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long P1 = 17;
const long long P2 = 19;
const long double PI = acos(-1);
const long long MAX = 63211236 + 10;
const long long INF = 1e9 + 10;
const long double EPS = 1e-9;
const int M = 5e3 + 2;
const int N = 1e6 + 10;
int d[2][M];
int main() {
  int n;
  cin >> n;
  if (n == 1) {
    cout << "!" << endl << 1 << " " << 0 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    cout << "? " << 0 << " " << i << endl;
    int ans;
    cin >> ans;
    d[0][i] = ans;
  }
  for (int i = 1; i < n; i++) {
    cout << "? " << i << " " << 0 << endl;
    int ans;
    cin >> ans;
    d[1][i] = ans;
  }
  vector<int> ansp;
  vector<int> p(n), b(n);
  int cntans = 0;
  for (int i = 0; i < n; i++) {
    p[0] = i;
    for (int j = 1; j < n; ++j) p[j] = p[0] ^ d[0][0] ^ d[1][j];
    for (int j = 0; j < n; ++j) b[j] = p[0] ^ d[0][j];
    bool ok = true;
    for (int j = 0; j < n; ++j)
      if (p[b[j]] != j) ok = false;
    if (ok) {
      ansp = p;
      cntans++;
    }
  }
  cout << "!" << endl << cntans << endl;
  for (auto t : ansp) cout << t << " ";
}
