#include <bits/stdc++.h>
using namespace std;
template <class T, class V>
ostream& operator<<(ostream& s, pair<T, V> a) {
  s << a.first << ' ' << a.second;
  return s;
}
long long int ask(long long int a, long long int b) {
  cout << "? " << a << ' ' << b << endl;
  long long int x;
  cin >> x;
  return x;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long int T = 1;
  for (long long int qq = 1; qq <= T; qq++) {
    long long int n;
    cin >> n;
    vector<pair<pair<long long int, long long int>, long long int> > v;
    vector<long long int> a;
    for (int i = 0; i < n; i++) {
      v.push_back(pair<pair<long long int, long long int>, long long int>(
          pair<long long int, long long int>(i, (i + 1) % n),
          ask(i, (i + 1) % n)));
      long long int x = v.back().second;
      v.push_back(pair<pair<long long int, long long int>, long long int>(
          pair<long long int, long long int>((i + 1) % n, (i + 1) % n),
          ask((i + 1) % n, (i + 1) % n)));
      a.push_back(x ^ (v.back().second));
    }
    long long int cnt = 0;
    vector<long long int> ans;
    vector<long long int> temp, temp2(n, 0);
    for (int i = 0; i < n; i++) {
      temp.clear();
      temp.push_back(i);
      temp2[i] = 0;
      for (int j = 0; j < n - 1; j++) {
        temp.push_back((temp.back()) ^ a[j]);
        if (temp.back() >= n) break;
        temp2[temp.back()] = (int)temp.size() - 1;
      }
      if (temp.back() >= n) continue;
      bool ok = true;
      for (auto x : v)
        if ((temp[x.first.first] ^ temp2[x.first.second]) != x.second)
          ok = false;
      if (ok) {
        cnt++;
        if (cnt == 1) ans = temp;
      }
    }
    cout << "!" << endl;
    cout << cnt << endl;
    for (auto x : ans) cout << x << ' ';
    cout << endl;
  }
  return 0;
}
