import java.util.*;
import java.io.*;

public class tiling_as implements Runnable {
    class Edge {
        int s;
        int t;
        int c;
        int f;
        Edge r;

        Edge(int s, int t, int c) {
            this.s = s;
            this.t = t;
            this.c = c;
        }

        public String toString() {
            return s + "->" + t + " (" + f + "/" + c + ")";
        }
    }

    class Graph {
        int vn;
        ArrayList<Edge>[] es;
        ArrayList<Edge>[] er;

        Graph(int vn) {
            this.vn = vn;
            es = new ArrayList[vn];
            er = new ArrayList[vn];
            for (int i = 0; i < vn; i++) {
                es[i] = new ArrayList<Edge>();
                er[i] = new ArrayList<Edge>();
            }
        }

        void addEdge(int s, int t, int c) {
            Edge e = new Edge(s, t, c);
            Edge erev = new Edge(t, s, 0);
            e.r = erev;
            erev.r = e;
            es[s].add(e);
            es[t].add(erev);
            er[t].add(e);
            er[s].add(erev);
        }

        boolean[] u;

        int dfs(int x, int t, int cmax) {
            if (x == t) {
                return cmax;
            }
            u[x] = true;
            for (Edge e : es[x]) {
                if (!u[e.t] && e.f < e.c) {
                    int cnew = Math.min(cmax, e.c - e.f);
                    int fv = dfs(e.t, t, cnew);
                    if (fv > 0) {
                        e.f += fv;
                        e.r.f -= fv;
                        return fv;
                    }
                }
            }
            return 0;
        }

        int maxFlow(int s, int t) {
            u = new boolean[vn];
            int f = 0;
            while (true) {
                Arrays.fill(u, false);
                int df = dfs(s, t, Integer.MAX_VALUE);
                if (df > 0) {
                    f += df;
                } else {
                    break;
                }
            }
            return f;
        }
    }

    Graph g;
    boolean[] u;

    public void solve() throws IOException {
        Scanner in = new Scanner(new File("tiling.in"));
        PrintWriter out = new PrintWriter("tiling.out");

        int n = in.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] ind = new int[n];
        int na = 0;
        int nb = 0;
        for (int i = 0; i < n; i++) {
            x[i] = in.nextInt();
            y[i] = in.nextInt();
            if (x[i] % 2 == 0) {
                ind[i] = na++;
            } else {
                ind[i] = nb++;
            }
        }
        int[] rind = new int[n];
        for (int i = 0; i < n; i++) {
            if (x[i] % 2 == 0) {
                rind[ind[i]] = i;
            } else {
                rind[na + ind[i]] = i;
            }
        }

        g = new Graph(n + 4);

        for (int i = 0; i < n; i++) {
            if (x[i] % 2 == 0) {
                g.addEdge(n, ind[i], 1);
                g.addEdge(n + 2, ind[i], 1);
            } else {
                g.addEdge(na + ind[i], n + 1, 1);
                g.addEdge(na + ind[i], n + 3, 1);
            }
        }
        g.addEdge(n + 1, n, 2 * n);
        g.addEdge(n + 2, n + 1, nb);
        g.addEdge(n, n + 3, na);

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (x[i] % 2 == 0 && x[j] % 2 != 0) {
                    if (y[i] == y[j] && Math.abs(x[i] - x[j]) == 1) {
                        g.addEdge(ind[i], na + ind[j], 1);
                    }
                    if (y[i] == y[j] + 1 && x[i] + y[i] == x[j] + y[j]) {
                        g.addEdge(ind[i], na + ind[j], 1);
                    }
                }
            }
        }

        int[] ans = new int[n];
        int f = g.maxFlow(n + 2, n + 3);
        if (f == n) {
            u = new boolean[n];
            int nm = 0;
            for (int i = 0; i < na; i++) {
                if (!u[i]) {
                    int j = i;
                    int[] path = new int[2 * n];
                    int h = n;
                    int t = n;
                    while (!u[j]) {
                        u[j] = true;
                        path[t++] = j;
                        ArrayList<Edge> edges = j < na ? g.es[j] : g.er[j];
                        for (Edge e : edges) {
                            if (e.f > 0 && e.s < n && e.t < n) {
                                e.f = 0;
                                if (j == e.s) {
                                    j = e.t;
                                } else {
                                    j = e.s;
                                }
                                break;
                            }
                        }
                    }
                    j = i;
                    while (true) {
                        ArrayList<Edge> edges = j < na ? g.es[j] : g.er[j];
                        for (Edge e : edges) {
                            if (e.f > 0 && e.s < n && e.t < n) {
                                e.f = 0;
                                if (j == e.s) {
                                    j = e.t;
                                } else {
                                    j = e.s;
                                }
                                break;
                            }
                        }
                        if (!u[j]) {
                            path[--h] = j;
                            u[j] = true;
                        } else {
                            break;
                        }
                    }

                    int sz = t - h;

                    int k;
                    for (k = h; k < t - 1; k += 2) {
                        nm++;
                        ans[rind[path[k]]] = nm;
                        ans[rind[path[k + 1]]] = nm;
                    }
                    if (k < t) {
                        ans[rind[path[k]]] = nm;
                    }

                }
            }
            out.println(nm);
            for (int q = 0; q < n; q++) {
                out.print(ans[q] + " ");
            }
        } else {
            out.println("No solution");
        }

        in.close();
        out.close();
    }

    public void run() {
        try {
            solve();
        } catch (IOException e) {
        }
    }

    public static void main(String[] arg) {
        new Thread(new tiling_as()).start();
    }
}