#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e3 + 5;
int ask[MAXN][MAXN];
int n;
int q(int x, int y) {
  if (ask[x][y] != -1) {
    return ask[x][y];
  }
  cout << "? " << x << " " << y << endl;
  cout.flush();
  int res;
  cin >> res;
  ask[x][y] = res;
  return res;
}
bool check(vector<int> p) {
  int n = p.size();
  vector<int> b(n);
  for (int i = 0; i < n; i++) {
    b[p[i]] = i;
  }
  for (int i = 0; i < n; i++) {
    if (q(0, i) != (p[0] ^ b[i])) {
      return false;
    }
  }
  for (int i = 0; i < n; i++) {
    if (q(i, 0) != (p[i] ^ b[0])) {
      return false;
    }
  }
  return true;
}
int main() {
  cin >> n;
  int cnt = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      ask[i][j] = -1;
    }
  }
  vector<int> ans;
  vector<int> p(n), t(n);
  for (int b0 = 0; b0 < n; b0++) {
    bool ok = true;
    for (int i = 0; i < n; i++) {
      t[i] = 0;
    }
    for (int i = 0; i < n; i++) {
      p[i] = q(i, 0) ^ b0;
      if (p[i] > n || t[p[i]]) {
        ok = false;
        break;
      }
      t[p[i]] = 1;
    }
    if (ok && check(p)) {
      cnt++;
      if (ans.size() == 0) {
        ans = p;
      }
    }
  }
  cout << "!" << endl;
  cout << cnt << endl;
  if (cnt) {
    for (int x : ans) {
      cout << x << " ";
    }
  }
}
