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.InputStreamReader;
import java.util.Comparator;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class E {
    static Comparator<int[]> arr_cmp = new Comparator<int[]>() {
        public int compare(int[] o1, int[] o2) {
            for (int i = 0; i < o1.length; i++)
                if (o1[i] != o2[i])
                    return (o1[i] < o2[i]) ? -1 : 1;
            return 0;
        }
    };
    static TreeSet<int[]> p1 = new TreeSet<>(arr_cmp);
    static TreeSet<int[]> p2 = new TreeSet<>(arr_cmp);
    static TreeSet<int[]> m1 = new TreeSet<>(arr_cmp);
    static int[] state;
    static int[] a;
    static int[] b;

    public static void remove(int i) {
        if (state[i] == 0) {
            p1.remove(new int[] { a[i], i });
            p2.remove(new int[] { b[i], i });
        } else if (state[i] == 1) {
            p1.remove(new int[] { b[i] - a[i], i });
            m1.remove(new int[] { a[i], i });
        } else if (state[i] == 2) {
            m1.remove(new int[] { b[i] - a[i], i });
        }
    }

    public static void add(int i) {
        if (state[i] == 0) {
            p1.add(new int[] { a[i], i });
            p2.add(new int[] { b[i], i });
        } else if (state[i] == 1) {
            p1.add(new int[] { b[i] - a[i], i });
            m1.add(new int[] { a[i], i });
        } else if (state[i] == 2) {
            m1.add(new int[] { b[i] - a[i], i });
        }
    }

    public static void main(String[] args) throws Exception {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer strtok;
        strtok = new StringTokenizer(in.readLine());
        int n = Integer.parseInt(strtok.nextToken());
        int m = Integer.parseInt(strtok.nextToken());
        a = new int[n];
        b = new int[n];
        state = new int[n];
        for (int i = 0; i < n; i++) {
            strtok = new StringTokenizer(in.readLine());
            a[i] = Integer.parseInt(strtok.nextToken());
            b[i] = Integer.parseInt(strtok.nextToken());
            add(i);
        }
        long total = 0;
        for (int i = 0; i < m; i++) {
            // +1 or -1 + 2
            int[] x0 = p1.isEmpty() ? null : p1.first();

            int[] x1 = p2.isEmpty() ? null : p2.first();
            int[] x2 = m1.isEmpty() ? null : m1.last();

            if (x0 == null) {
                remove(x1[1]);
                remove(x2[1]);
                state[x1[1]] += 2;
                state[x2[1]] -= 1;
                total += x1[0] - x2[0];
                add(x1[1]);
                add(x2[1]);
            } else if (x1 == null || x2 == null) {
                remove(x0[1]);
                state[x0[1]]++;
                total += x0[0];
                add(x0[1]);
            } else {
                long left = x0[0];
                long right = x1[0] - x2[0];
                if (left > right) {
                    remove(x1[1]);
                    remove(x2[1]);
                    state[x1[1]] += 2;
                    state[x2[1]] -= 1;
                    total += x1[0] - x2[0];
                    add(x1[1]);
                    add(x2[1]);
                } else {
                    remove(x0[1]);
                    state[x0[1]]++;
                    total += x0[0];
                    add(x0[1]);
                }
            }
        }
        StringBuilder out = new StringBuilder();
        for (int i = 0; i < n; i++)
            out.append((char) (state[i] + '0'));
        System.out.println(total);
        System.out.println(out);
    }
}