Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. 

Alyona is a capricious girl so after she gets the array, she inspects m of its subarrays. Subarray is a set of some subsequent elements of the array. The i-th subarray is described with two integers li and ri, and its elements are a[li], a[li + 1], ..., a[ri].

Alyona is going to find mex for each of the chosen subarrays. Among these m mexes the girl is going to find the smallest. She wants this minimum mex to be as large as possible. 

You are to find an array a of n elements so that the minimum mex among those chosen by Alyona subarrays is as large as possible.

The mex of a set S is a minimum possible non-negative integer that is not in S.

Input

The first line contains two integers n and m (1 ≤ n, m ≤ 105).

The next m lines contain information about the subarrays chosen by Alyona. The i-th of these lines contains two integers li and ri (1 ≤ li ≤ ri ≤ n), that describe the subarray a[li], a[li + 1], ..., a[ri].

Output

In the first line print single integer — the maximum possible minimum mex.

In the second line print n integers — the array a. All the elements in a should be between 0 and 109.

It is guaranteed that there is an optimal answer in which all the elements in a are between 0 and 109.

If there are multiple solutions, print any of them.

Examples

Input

5 3
1 3
2 5
4 5


Output

2
1 0 2 1 0


Input

4 2
1 4
2 4


Output

3
5 2 0 1

Note

The first example: the mex of the subarray (1, 3) is equal to 3, the mex of the subarray (2, 5) is equal to 3, the mex of the subarray (4, 5) is equal to 2 as well, thus the minumal mex among the subarrays chosen by Alyona is equal to 2.
import java.io.*;
import java.math.*;
import java.util.*;

/**
 *
 * @author Saju
 *
 */

public class Main {

    private static int dx[] = { 1, 0, -1, 0 };
    private static int dy[] = { 0, -1, 0, 1 };

    private static final long INF = (long) Math.pow(10, 16);
    private static final int INT_INF = Integer.MAX_VALUE;
    private static final long NEG_INF = Long.MIN_VALUE;
    private static final int NEG_INT_INF = Integer.MIN_VALUE;
    private static final double EPSILON = 1e-10;

    private static final long MAX = (long) 1e12;
    
    private static final long MOD = 1000000007;

    private static final int MAXN = 200001;
    private static final int MAXA = 1000007;
    private static final int MAXLOG = 22;
    private static final double PI = Math.acos(-1);
    
	public static void main(String[] args) throws IOException {

		InputReader in = new InputReader(System.in);
//		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

//         InputReader in = new InputReader(new FileInputStream("src/test.in"));
//         PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("src/test.out")));

		
		
/*




*/		
	
		int n = in.nextInt();
		int m = in.nextInt();
		
		int min = INT_INF;
		
		Pair[] pairs = new Pair[m];
		for(int i = 0; i < m; i++) {
			pairs[i] = new Pair(in.nextInt(), in.nextInt());
			min = min(min, pairs[i].r - pairs[i].l + 1);
		}
//		System.out.println(min);
		int arr[] = new int[n];
		int cnt = 0;
		for(int i = 0; i < n; i++) {
			arr[i] = cnt++;
			if(cnt == min) {
				cnt = 0;
			}
		}
		
//		int mex = INT_INF;
//		for(int i = 0; i < m; i++) {
//			int l = pairs[i].l - 1;
//			int r = pairs[i].r - 1;
//			int len = r - l + 1;
//			if(len >= min) {
//				mex = min(mex, min);
//			}
//			else {
//				
//			}
//		}
		
		out.println(min);
		
		for(int i = 0; i < n; i++) {
			out.print(arr[i]);
			if(i < n - 1) {
				out.print(" ");
			}
			else {
				out.println();
			}
		}
		
		in.close();
		out.flush();
		out.close();
		System.exit(0);
	}
	
	private static class Pair{
		int l;
		int r;
		Pair(int l, int r){
			this.l = l;
			this.r = r;
		}
	}
	

	/*
	 * return the number of elements in list that are less than or equal to the val
	 */
	private static long upperBound(List<Long> list, long val) {
		int start = 0;
		int len = list.size();
		int end = len - 1;
		int mid = 0;

		while (true) {
			if (start > end) {
				break;
			}
			mid = (start + end) / 2;
			long v = list.get(mid);
			if (v == val) {
				start = mid;
				while(start < end) {
					mid = (start + end) / 2;
					if(list.get(mid) == val) {
						if(mid + 1 < len && list.get(mid + 1) == val) {
							start = mid + 1;
						}
						else {
							return mid + 1;
						}
					}
					else {
						end = mid - 1;
					}
				}
				return start + 1;
			}
			if (v > val) {
				end = mid - 1;
			} else {
				start = mid + 1;
			}
		}
		if (list.get(mid) < val) {
			return mid + 1;
		}
		return mid;
	}


	private static boolean isPalindrome(String str) {
		StringBuilder sb = new StringBuilder();
		sb.append(str);
		String str1 = sb.reverse().toString();
		return str.equals(str1);
	}

	private static String getBinaryStr(long n, int j) {
		String str = Long.toBinaryString(n);
		int k = str.length();
		for (int i = 1; i <= j - k; i++) {
			str = "0" + str;
		}

		return str;
	}
	
	private static long modInverse(long r) {
		return bigMod(r, MOD - 2, MOD);
	}
	
	private static long bigMod(long n, long k, long m) {

        long ans = 1;
        while (k > 0) {
            if ((k & 1) == 1) {
                ans = (ans * n) % m;
            }
            n = (n * n) % m;
            k >>= 1;
        }
        return ans;
    }
    
	private static long ceil(long n, long x) {
		long div = n / x;
        if(div * x != n) {
            div++;
        }
        return div;
	}
	
    private static int ceil(int n, int x) {
        int div = n / x;
        if(div * x != n) {
            div++;
        }
        return div;
    }

    
    private static int abs(int x) {
        if (x < 0) {
            return -x;
        }
        return x;
    }
    
    private static double abs(double x) {
        if (x < 0) {
            return -x;
        }
        return x;
    }

    private static long abs(long x) {
        if(x < 0) {
            return -x;
        }
        return x;
    }
    
    private static long lcm(long a, long b) {
        return (a * b) / gcd(a, b);
    }

    private static int lcm(int a, int b) {
        return (a * b) / gcd(a, b);
    }

    private static int gcd(int a, int b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    
    private static long gcd(long a, long b) {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }

    private static int log(long x, int base) {
        return (int) (Math.log(x) / Math.log(base));
    }

    private static int log(long x, long base) {
        return (int) (Math.log(x) / Math.log(base));
    }
    
    private static long min(long a, long b) {
        if (a < b) {
            return a;
        }
        return b;
    }

    private static int min(int a, int b) {
        if (a < b) {
            return a;
        }
        return b;
    }

    private static long max(long a, long b) {
        if (a < b) {
            return b;
        }
        return a;
    }

    private static int max(int a, int b) {
        if (a < b) {
            return b;
        }
        return a;
    }

    private static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());

                }
            } catch (IOException e) {
                return null;
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            String line = null;
            try {
                tokenizer = null;
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public boolean hasNext() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (Exception e) {
                return false;
            }
            return true;
        }
        
        public int[] nextIntArr(int n) {
        	int arr[] = new int[n];
    		for(int i = 0; i < n; i++) {
    			arr[i] = nextInt();
    		}
    		return arr;
        }
        
        public long[] nextLongArr(int n) {
        	long arr[] = new long[n];
    		for(int i = 0; i < n; i++) {
    			arr[i] = nextLong();
    		}
    		return arr;
        }
        
        public int[] nextIntArr1(int n) {
        	int arr[] = new int[n + 1];
    		for(int i = 1; i <= n; i++) {
    			arr[i] = nextInt();
    		}
    		return arr;
        }
        
        public long[] nextLongArr1(int n) {
        	long arr[] = new long[n + 1];
    		for(int i = 1; i <= n; i++) {
    			arr[i] = nextLong();
    		}
    		return arr;
        }
       
        public void close() {
        	try {
        		if(reader != null) {
        			reader.close();
        		}
        	}
        	catch(Exception e) {
        		
        	}
        	
        	
        }
    }

}