Problem: Everyone who has played Cut the Rope knows full well how the gameplay is organized. All levels in the game are divided into boxes. Initially only one box with some levels is available. Player should complete levels to earn stars, collecting stars opens new box with levels.

<image>

Imagine that you are playing Cut the Rope for the first time. Currently you have only the levels of the first box (by the way, it is called "Cardboard Box"). Each level is characterized by two integers: ai — how long it takes to complete the level for one star, bi — how long it takes to complete the level for two stars (ai < bi).

You want to open the next box as quickly as possible. So, you need to earn at least w stars. How do make it happen? Note that the level can be passed only once: either for one star or for two. You do not necessarily need to pass all the levels.

Input

The first line contains two integers n and w (1 ≤ n ≤ 3·105; 1 ≤ w ≤ 2n) — the number of levels in the first box and the number of stars you need to open another box. Each of the following n lines contains two integers ai and bi (1 ≤ ai < bi ≤ 109) — the attributes of the i-th level.

Output

In the first line print integer t — the minimum time you need to open the next box. 

In the next line, print n digits without spaces — the description of the optimal scenario: 

  * if you need to pass the i-th level for one star, the i-th digit should equal 1; 
  * if you need to pass the i-th level for two stars, the i-th digit should equal 2; 
  * if you do not need to pass the i-th level at all, the i-th digit should equal 0. 

Examples

Input

2 3
1 2
1 2


Output

3
12


Input

5 3
10 20
5 10
10 20
6 9
25 30


Output

14
01020

Note

In the first test sample, answer 21 is also assumed correct.

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.TreeSet;

public class D {
	static InputStreamReader isr = new InputStreamReader(System.in);
	static BufferedReader br = new BufferedReader(isr);

	static int[] readIntArray() throws IOException {
		String[] v = br.readLine().split(" ");
		int[] ans = new int[v.length];

		for (int i = 0; i < ans.length; i++) {
			ans[i] = Integer.valueOf(v[i]);
		}

		return ans;
	}

	static class Level2 implements Comparable<Level2> {
		public int id;
		public int a,b;

		public Level2(int id, int a, int b) {
			this.id = id;
			this.a = a;
			this.b = b;
		}

		@Override
		public int compareTo(Level2 o) {
			return new Integer(this.b).compareTo(o.b);
		}
	}
	
	static class Level implements Comparable<Level> {
		public int id;
		public int time;
		public int stars;
		public double avg;

		public Level(int id, int time, int stars) {
			this.id = id;
			this.time = time;
			this.stars = stars;
			this.avg = time;
			this.avg /= stars;
		}

		@Override
		public int compareTo(Level o) {
			return new Double(this.avg).compareTo(o.avg);
		}
	}

	static class R implements Comparable<R> {
		public int id;
		public int diff;

		public R(int id) {
			this.id = id;
			this.diff = levels[id][1] - levels[id][0];
		}
		
		public R(int id, int diff) {
			this.id = id;
			this.diff = diff;
		}

		@Override
		public int compareTo(R arg0) {
			int r = new Integer(this.diff).compareTo(arg0.diff);
			if (r == 0) {
				return new Integer(this.id).compareTo(arg0.id);
			} else {
				return r;
			}
		}
	}

	static int n, w;
	static int[][] levels;
	static List<Level> lev;
	static List<Level2> lev2;
	static TreeSet<R> twoToOne, twoToZero, oneToTwo, oneToZero, zeroToOne, zeroToTwo;
	static HashMap<Integer, R> oneToZeroByID;
	static HashMap<Integer, Integer> incl;
	
	static TreeSet<R> magic;
	static HashMap<Integer, R> magicByID;
	static long magicTime = 0;
	
	static void clean(int desiredCount) {
		while (magic.size() > desiredCount) {
			R r = magic.last();
			magic.remove(r);
			magicTime -= r.diff;
		}
	}
	
	static long solve(int stop) {
		magicTime = 0;
		magic = new TreeSet<D.R>();
		magicByID = new HashMap<Integer, D.R>();
		
		int bestInd = -1;
		long bestTime = Long.MAX_VALUE;
		for (int i = 0; i < lev2.size(); i++) {
			Level2 el = lev2.get(i);
			R r = new R(el.id, el.a);
			magic.add(r);
			magicByID.put(el.id, r);
			magicTime += el.a;
		}
		
		long[] prefSum = new long[n];
		Level2 first = lev2.get(0);
		prefSum[0] = first.a;
		for (int i = 1; i < prefSum.length; i++) {
			prefSum[i] = prefSum[i-1];
			prefSum[i] += lev2.get(i).a;
		}
		
		for (int i = -1; i < lev2.size() && w - i - 1 >= 0; i++) {
			long time = i == -1 ? 0 : prefSum[i];
			int remw = w - i - 1;
			
			if (i == -1) {
				
			} else {	
				Level2 el = lev2.get(i);
				if (magic.remove(magicByID.get(el.id))) {
					magicTime -= levels[el.id][0];
				}
				R r = new R(el.id, el.b - el.a);
				magic.add(r);
				magicByID.put(el.id, r);
				magicTime += r.diff;
			}
			
			clean(remw);
			
			long currentTime = magicTime + time;
			if (stop == i) {
				return currentTime;
			}
			if (currentTime > bestTime) {
				return i - 1;
			}
			
			if (magic.size() + (i+1) >= w)
				bestTime = currentTime;
		}
		
		return Math.min(lev2.size() - 1, w-1);
	}
	
	public static void main(String[] args) throws IOException {
		int[] l = readIntArray();
		n = l[0];
		w = l[1];
		levels = new int[n][];
		lev2 = new ArrayList<D.Level2>();
		for (int i = 0; i < n; i++) {
			levels[i] = readIntArray();
			lev2.add(new Level2(i, levels[i][0], levels[i][1]));
		}
		Collections.sort(lev2);
		
		long ind = solve(-2);
		long ans = solve((int)ind);
		
		// print
		
		char[] detailedAnswer = new char[n];
		for (int i = 0; i < lev2.size(); i++) {
			if (i <= ind) {
				detailedAnswer[lev2.get(i).id] = '1';
			} else {
				detailedAnswer[lev2.get(i).id] = '0';
			}
		}
		
		Iterator<R> it = magic.iterator();
		while(it.hasNext()) {
			R r = it.next();
			if (detailedAnswer[r.id] == '1') {
				detailedAnswer[r.id] = '2';
			} else {
				detailedAnswer[r.id] = '1';
			}
		}
				
		System.out.println(ans);
		System.out.println(new String(detailedAnswer));
	}
}