#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e9 + 113;
const long long maxn = 5000 + 113;
bool used[maxn];
int main() {
  srand(time(NULL));
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<pair<pair<int, int>, int>> we;
  for (int i = 0; i < n; i++) {
    cout << "? 0 " << i << endl;
    cout.flush();
    int s;
    cin >> s;
    we.push_back({{0, i}, s});
  }
  for (int i = 1; i < n; i++) {
    cout << "? " << i << " 0" << endl;
    cout.flush();
    int s;
    cin >> s;
    we.push_back({{i, 0}, s});
  }
  int k = 1;
  vector<int> p, b;
  vector<int> ansp;
  ansp.resize(n);
  long long ans = 0;
  p.resize(n), b.resize(n);
  for (int x = 0; x < n; x++) {
    for (int i = 0; i < n; i++) p[i] = 0, b[i] = 0;
    p[0] = x;
    for (int j = 0; j < we.size(); j++) {
      if (we[j].first.first == 0)
        b[we[j].first.second] = p[0] ^ we[j].second;
      else
        p[we[j].first.first] = b[0] ^ we[j].second;
    }
    bool tr = true;
    for (int i = 0; i < n; i++) {
      if (used[p[i]] == k || p[i] >= n) {
        tr = false;
        break;
      }
      used[p[i]] = k;
    }
    k++;
    if (!tr) continue;
    for (int i = 0; i < n; i++) {
      if (used[b[i]] == k || b[i] >= n) {
        tr = false;
        break;
      }
      used[b[i]] = k;
    }
    k++;
    if (!tr) continue;
    for (int i = 0; i < n; i++) {
      if (p[b[i]] != i) {
        tr = false;
        break;
      }
    }
    if (!tr) continue;
    if (!ans)
      for (int i = 0; i < n; i++) ansp[i] = p[i];
    ans++;
  }
  cout << "!" << endl;
  cout << ans << endl;
  for (int i = 0; i < n; i++) cout << ansp[i] << " ";
  cout << endl;
  cout.flush();
}
