#include <iostream>
#include <vector>

using namespace std;

void solve2(int n) {
    int r;
    int l = r = 0;
    int ans = 1;
    int curr_sym = 1;
    vector<int> res(n);
    while (l < n) {
        while (r < n and ans == 1) {
            cout << "? " << l + 1 << ' ' << r + 1 << endl;
            cin >> ans;
            if (ans == 1) {
                r++;
            }
        }
        for (int i = l; i < r; i++) {
            res[i] = curr_sym;
        }
        curr_sym = 3 - curr_sym;
        l = r;
        r++;
        ans = 1;
    }
    cout << "Ready!" << endl;
    int max_el = 0;
    for (int i = 0; i < n; i++) {
        max_el = max(max_el, res[i]);
    }
    cout << max_el << endl;
    for (int i = 0; i < n; i++) {
        cout << res[i] << ' ';
    }
    cout << endl;
}

vector<vector<int> > graph;
vector<int> used;

void dfs(int u, int color) {
    used[u] = color;
    for (int v : graph[u]) {
        if (!used[v]) {
            dfs(v, color);
        }
    }
}

vector<vector<int> > asked;
vector<vector<int> > amounts;

int get(int l, int r) {
    if (asked[l][r]) {
        return amounts[l][r];
    } else if (r < asked.size() and asked[l][r + 1] and r > 0 and asked[l][r - 1] and amounts[l][r - 1] == amounts[l][r + 1]) {
        return amounts[l][r] = amounts[l][r - 1];
    
    } else {
        asked[l][r] = true;
        cout << "? " << l + 1 << ' ' << r + 1 << endl;
        cin >> amounts[l][r];
        return amounts[l][r];
    }
}
int main() {
    int n, r;
    cin >> n;
    asked.resize(n, vector<int>(n, 0));
    amounts.resize(n, vector<int>(n));
    graph.resize(n);
    for (int i = 0; i < n - 1; i++) {
        if (get(i, i + 1) == 1) {
            graph[i].push_back(i + 1);
            graph[i + 1].push_back(i);
            continue;
        } else if (get(i + 1, n - 1) == get(i, n - 1) - 1) {
            continue;
        }   
        int l = i + 1;
        r = n - 1;
        while (l + 1 < r) {
            int m = (l + r) / 2;
            if (get(i + 1, m) == get(i, m)) {
                r = m;
            } else {
                l = m;
            }
        }
    }
    used.resize(n, 0);
    int cnt = 1;
    for (int i = 0; i < n; i++) {
        if (!used[i]) {
            dfs(i, cnt);
            cnt++;
        }
    }
    cout << "Ready!" << endl;
    cout << cnt - 1 << endl;
    for (int i = 0; i < n; i++) {
        cout << used[i] << ' ';
    }
    cout << endl;
}
