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.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Iterator;
import java.util.Comparator;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.util.TreeSet;
import java.util.StringTokenizer;
import java.util.LinkedList;
import java.util.Collection;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Vadim
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
    class Level {
        int i;
        int a;
        int b;

        Level(int i, int a, int b) {
            this.i = i;
            this.a = a;
            this.b = b;
        }
    }
    private Level next(TreeSet<Level> set) {
        Iterator<Level> iterator = set.iterator();
        if(iterator.hasNext()) {
            return iterator.next();
        }
        return null;
    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.ni();
        int w = in.ni();
        int a[] = new int[n];
        int b[] = new int[n];
        List<Level> levels = new LinkedList<Level>();

        for (int i = 0; i < n; i++) {
            a[i] = in.ni();
            b[i] = in.ni();
            levels.add(new Level(i, a[i], b[i]));
        }
        TreeSet<Level> oneStar = new TreeSet<Level>(new Comparator<Level>() {
            @Override
            public int compare(Level o1, Level o2) {
                if(o1.a == o2.a) {
                    return o1.i-o2.i;
                }
                return o1.a-o2.a;
            }
        });
        TreeSet<Level> twoStar = new TreeSet<Level>(new Comparator<Level>() {
            @Override
            public int compare(Level o1, Level o2) {
                if(o1.b == o2.b) {
                    return o1.i-o2.i;
                }
                return o1.b - o2.b;
            }
        });

        TreeSet<Level> oneStarAdded = new TreeSet<Level>(new Comparator<Level>() {
            @Override
            public int compare(Level o1, Level o2) {
                if(o1.a == o2.a) {
                    return o2.i-o1.i;
                }
                return o2.a - o1.a;
            }
        });
        TreeSet<Level> twoStarAdded = new TreeSet<Level>(new Comparator<Level>() {
            @Override
            public int compare(Level o1, Level o2) {
                if(o1.b == o2.b) {
                    return o2.i-o1.i;
                }
                return o2.b - o1.b;
            }
        });

        TreeSet<Level> exchange12 = new TreeSet<Level>(new Comparator<Level>() {
            @Override
            public int compare(Level o1, Level o2) {
                if(o1.b - o1.a == o2.b - o2.a) {
                    return o1.i-o2.i;
                }
                return (o1.b - o1.a) - (o2.b - o2.a);
            }
        });
        TreeSet<Level> exchange21 = new TreeSet<Level>(new Comparator<Level>() {
            @Override
            public int compare(Level o1, Level o2) {
                if(o1.b - o1.a == o2.b - o2.a) {
                    return o1.i-o2.i;
                }
                return  (o2.b - o2.a) - (o1.b - o1.a);
            }
        });
        
        oneStar.addAll(levels);
        twoStar.addAll(levels);
        long cost = 0;

        Level firstLevel = next(oneStar);

        cost += firstLevel.a;
        oneStarAdded.add(firstLevel);
        exchange12.add(firstLevel);
        oneStar.remove(firstLevel);
        twoStar.remove(firstLevel);
        for (int k = 2; k <= w; k++) {
            Level oneStarNextMin = next(oneStar);
            Level twoStarNextMin = next(twoStar);
            int oneStarAddCost = Integer.MAX_VALUE;
            if(oneStarNextMin != null) {
                oneStarAddCost = oneStarNextMin.a;
            }
            int twoStarAddCost = Integer.MAX_VALUE;
            Level oneStarRemove = next(oneStarAdded);
            if(twoStarNextMin != null && oneStarRemove != null) {
                twoStarAddCost = twoStarNextMin.b-oneStarRemove.a;
            }
            int changeCost12 = Integer.MAX_VALUE;
            Level changeStar12 = next(exchange12);
            if(changeStar12 != null) {
                changeCost12 = changeStar12.b-changeStar12.a;
            }
            int changeCost21 = Integer.MAX_VALUE;
            Level changeStar21 = next(exchange21);
            if(twoStarNextMin != null && changeStar21 != null) {
                changeCost21 = twoStarNextMin.b -(changeStar21.b-changeStar21.a);
            }
            if(oneStarAddCost <= twoStarAddCost && oneStarAddCost <= changeCost12 && oneStarAddCost <= changeCost21) {
                cost += oneStarAddCost;
                oneStar.remove(oneStarNextMin);
                oneStarAdded.add(oneStarNextMin);
                exchange12.add(oneStarNextMin);
                twoStar.remove(oneStarNextMin);
            } else if(twoStarAddCost <= oneStarAddCost && twoStarAddCost <= changeCost12 && twoStarAddCost <= changeCost21) {
                cost += twoStarAddCost;
                oneStarAdded.remove(oneStarRemove);
                oneStar.add(oneStarRemove);
                exchange12.remove(oneStarRemove);
                twoStar.add(oneStarRemove);
                twoStarAdded.add(twoStarNextMin);
                twoStar.remove(twoStarNextMin);
                oneStar.remove(twoStarNextMin);
                exchange21.add(twoStarNextMin);
            } else if(changeCost12 <= oneStarAddCost && changeCost12 <= twoStarAddCost && changeCost12 <= changeCost21){
                cost += changeCost12;
                oneStarAdded.remove(changeStar12);
                exchange12.remove(changeStar12);
                twoStarAdded.add(changeStar12);
                exchange21.add(changeStar12);
            } else {
                cost += changeCost21;
                twoStarAdded.remove(changeStar21);
                oneStarAdded.add(changeStar21);
                exchange12.add(changeStar21);
                exchange21.remove(changeStar21);

                twoStarAdded.add(twoStarNextMin);
                twoStar.remove(twoStarNextMin);
                oneStar.remove(twoStarNextMin);
                exchange21.add(twoStarNextMin);
            }
        }
        out.println(cost);
        int[]res = new int[n];
        for (Level level : oneStarAdded) {
            res[level.i] = 1;
        }
        for (Level level : twoStarAdded) {
            res[level.i] = 2;
        }
        for (int i = 0; i < res.length; i++) {
            out.print(res[i]);
        }
        out.println();
    }
}

class InputReader  extends BufferedReader {
    public InputReader(InputStream st) {
        super(new InputStreamReader(st));
    }

    public int nextInt() {
        try {
            int c = read();

            while (isWhiteSpace(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int ret = 0;
            while (c >= 0 && !isWhiteSpace(c)) {
                if (c < '0' || c > '9') {
                    throw new RuntimeException();
                }
                ret = ret * 10 + c - '0';
                c = read();
            }
            return ret * sgn;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public int ni() {
        return nextInt();
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }


    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }



}