#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
long long n;
int arr[5001][2];
int nbr[5001][2];
int mkd[5001][2];
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cout << "? " << 0 << " " << i << endl;
    cin >> arr[i][0];
    cout << "? " << i << " " << 0 << endl;
    cin >> arr[i][1];
  }
  int ans = 0, pb0;
  for (int b0 = 0; b0 < n; b0++) {
    int k = 1;
    memset(mkd, 0, sizeof mkd);
    for (int i = 0; i < n; i++) {
      nbr[i][0] = b0 ^ arr[i][1];
      if (nbr[i][0] >= n || mkd[nbr[i][0]][0]) {
        k = 0;
        break;
      }
      mkd[nbr[i][0]][0] = 1;
    }
    if (!k) continue;
    for (int i = 0; i < n; i++) {
      nbr[i][1] = nbr[0][0] ^ arr[i][0];
      if (nbr[i][1] >= n || mkd[nbr[i][1]][1]) {
        k = 0;
        break;
      }
      mkd[nbr[i][1]][1] = 1;
    }
    for (int i = 0; i < n; i++) {
      if (nbr[nbr[i][0]][1] != i) k = 0;
    }
    if (b0 != nbr[0][1]) k = 0;
    ans += k;
    if (k) pb0 = b0;
  }
  cout << "!\n" << ans << "\n";
  for (int i = 0; i < n; i++) cout << (pb0 ^ arr[i][1]) << " ";
  cout << endl;
}
