You are given a directed graph with n vertices and m directed edges without self-loops or multiple edges.

Let's denote the k-coloring of a digraph as following: you color each edge in one of k colors. The k-coloring is good if and only if there no cycle formed by edges of same color.

Find a good k-coloring of given digraph with minimum possible k.

Input

The first line contains two integers n and m (2 ≤ n ≤ 5000, 1 ≤ m ≤ 5000) — the number of vertices and edges in the digraph, respectively.

Next m lines contain description of edges — one per line. Each edge is a pair of integers u and v (1 ≤ u, v ≤ n, u ≠ v) — there is directed edge from u to v in the graph.

It is guaranteed that each ordered pair (u, v) appears in the list of edges at most once.

Output

In the first line print single integer k — the number of used colors in a good k-coloring of given graph.

In the second line print m integers c_1, c_2, ..., c_m (1 ≤ c_i ≤ k), where c_i is a color of the i-th edge (in order as they are given in the input).

If there are multiple answers print any of them (you still have to minimize k).

Examples

Input


4 5
1 2
1 3
3 4
2 4
1 4


Output


1
1 1 1 1 1 


Input


3 3
1 2
2 3
3 1


Output


2
1 1 2 
import java.util.*;
public class Contest1217D {
    public static Scanner enter=new Scanner(System.in);
    public static HashMap<pair, Integer> order=new HashMap<>();
    public static int[] ans;
    public static int[] firstTime;
    public static int[] lastTime;
    public static int time=0;
    public static LinkedList<Integer>[] vert;
    public static boolean was[];
    public static boolean flag=true;
    public static void main(String[] args) {
        int n=enter.nextInt();
        int m=enter.nextInt();
        vert=new LinkedList[n+1];
        was=new boolean[n+1];
        ans=new int[m];
        firstTime=new int[n+1];
        lastTime=new int[n+1];
        Arrays.fill(was, false);
        for (int i = 0; i <n+1 ; i++) {
            vert[i]=new LinkedList<>();
        }
        for (int i = 0; i < m; i++) {
            int l=enter.nextInt();
            int r=enter.nextInt();
            vert[l].addLast(r);
            order.put(new pair(l,r),i);
        }
        for (int i = 1; i <= n ; i++) {
            if(was[i]) continue;
            DSU(i);
        }
        Arrays.fill(was, false);
        for (int i = 1; i <= n ; i++) {
            if(was[i]) continue;
            DSU2(i);
        }
        if(flag) System.out.println(1);
        else System.out.println(2);
        for (int i = 0; i <m ; i++) {
            System.out.print((ans[i]+1)+" ");
        }
    }
    public static boolean isBackEdge(int v, int a){ //a is a parent of v
        return firstTime[a]<firstTime[v];
    }

    public static void DSU2(int v){
        was[v]=true;
        for (int a: vert[v]) {
            if(firstTime[a]<firstTime[v] && lastTime[a]>lastTime[v]){
                ans[order.get(new pair(v,a))]=1;
                flag=false;
            }
            else if(!was[a]){
                DSU2(a);
            }
        }
    }

    public static void DSU(int v){
        was[v]=true;
        firstTime[v]=time;
        time++;
        for (int a: vert[v]) {
            if(!was[a]){
                DSU(a);
            }
        }
        lastTime[v]=time;
        time++;
    }

    static class pair{
        int u;
        int v;

        public pair(int u, int v) {
            this.u = u;
            this.v = v;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o) return true;
            if (o == null || getClass() != o.getClass()) return false;
            pair pair = (pair) o;
            return u == pair.u &&
                    v == pair.v;
        }

        @Override
        public int hashCode() {

            return Objects.hash(u, v);
        }
    }
}
