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.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Collections.*;
import static java.lang.Math.*;
import static java.lang.Math.min;
import static java.util.Arrays.*;
import static java.math.BigInteger.*;


public class Main{

    void run(){
        Locale.setDefault(Locale.US);
        boolean my;
        try {
            my = System.getProperty("MY_LOCAL") != null;
        } catch (Exception e) {
            my = false;
        }
        try{
            err = System.err;
            if( my ){
                sc  = new FastScanner(new BufferedReader(new FileReader("input.txt")));
//                sc  = new FastScanner(new BufferedReader(new FileReader("C:\\myTest.txt")));
                out = new PrintWriter   (new FileWriter("output.txt"));
            }
            else {
                sc = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }
//            out = new PrintWriter(new OutputStreamWriter(System.out));
        }catch(Exception e){
            MLE();
        }
        if( my )
            tBeg = System.currentTimeMillis();
        solve();
        if( my )
            err.println( "TIME: " + (System.currentTimeMillis() - tBeg ) / 1e3 );
        exit(0);
    }

    void exit( int val ){
        err.flush();
        out.flush();
        System.exit(val);
    }

    double tBeg;
    FastScanner sc;
    PrintWriter out;
    PrintStream err;

    class FastScanner{

        StringTokenizer st;
        BufferedReader br;

        FastScanner( BufferedReader _br ){
            br = _br;
        }

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

        String next(){
            while( st==null || !st.hasMoreElements() )
                st = new StringTokenizer(readLine());
            return st.nextToken();
        }

        int nextInt(){ return Integer.parseInt(next()); }
        long nextLong(){ return Long.parseLong(next()); }
        double nextDouble(){ return Double.parseDouble(next()); }
    }

    void MLE(){
        int[][] arr = new int[1024*1024][]; for( int i = 0; i < 1024*1024; ++i ) arr[i] = new int[1024*1024];
    }

    void MLE( boolean doNotMLE ){ if( !doNotMLE ) MLE(); }

    void TLE(){
        for(;;);
    }

    public static void main(String[] args) {
        new Main().run();
//        new Thread( null, new Runnable() {
//            @Override
//            public void run() {
//                new Main().run();
//            }
//        }, "Lolka", 256_000_000L ).run();
    }

    ////////////////////////////////////////////////////////////////

    class Item{
        long a, b;
        int id;
        Item( int _a, int _b, int _id ){
            a  = _a;
            b  = _b;
            id = _id;
        }
    }


    Comparator<Item> cmpId = (x, y) -> Long.compare(x.id, y.id);
    Comparator<Item> cmpA  = (x, y) -> Long.compare(x.a, y.a);
    Comparator<Item> cmpB  = (x, y) -> Long.compare(x.b, y.b);
    Comparator<Item> cmpBsubA  = (x, y) -> Long.compare( x.b-x.a, y.b-y.a );

    int n, w;
    TreeSet<Item> ts0a     = new TreeSet<>(     cmpA.thenComparing(cmpId::compare) );
    TreeSet<Item> ts0b     = new TreeSet<>(     cmpB.thenComparing(cmpId::compare) );
    TreeSet<Item> ts1A     = new TreeSet<>(     cmpA.thenComparing(cmpId::compare) );
    TreeSet<Item> ts1BsubA = new TreeSet<>( cmpBsubA.thenComparing(cmpId::compare) );
    TreeSet<Item> ts2BsubA = new TreeSet<>( cmpBsubA.thenComparing(cmpId::compare) );
    long inf = Long.MAX_VALUE/10;


    void solve(){
        n = sc.nextInt();
        w = sc.nextInt();
        for( int i = 0; i < n; i++ ){
            Item it = new Item(sc.nextInt(),sc.nextInt(),i);
            ts0a.add( it );
            ts0b.add( it );
        }

        long ans = 0;
        for( int cntStars = 1; cntStars <= w; cntStars++ ){
            long ans1 = inf;
            long ans2 = inf;
            long ans3 = inf;
            long ans4 = inf;

            if( !ts0a.isEmpty() ){
                ans1 = ts0a.first().a;
            }

            if( !ts1A.isEmpty() ){
                Item it10 = ts1A.last();
                ts0b.add( it10 );
                ans2 = ts0b.first().b - it10.a;
                ts0b.remove(it10);
            }

            if( !ts1A.isEmpty() ){
                ans3 = ts1BsubA.first().b - ts1BsubA.first().a;
            }

            if( !ts2BsubA.isEmpty() && !ts0a.isEmpty() ){
                ans4 = ts0b.first().b - (ts2BsubA.last().b - ts2BsubA.last().a);
            }

            long delta = min( min(ans1,ans2), min(ans3,ans4) );
            ans += delta;
//            err.printf( "%2d) %2d %2d %2d\n", cntStars, ans1, ans2, ans3 );

            if( delta == ans1 ){
                Item it01 = ts0a.pollFirst();
                ts0b.remove(it01);
                ts1BsubA.add( it01 );
                ts1A.add( it01 );
            }
            else if( delta == ans2 ){
                Item it10 = ts1A.pollLast();
                ts1BsubA.remove(it10);
                ts0a.add( it10 );
                ts0b.add( it10 );

                Item it02 = ts0b.pollFirst();
                ts0a.remove(it02);

                ts2BsubA.add( it02 );
            }
            else if( delta == ans3 ){
                Item it12 = ts1BsubA.pollFirst();
                ts1A.remove(it12);
                ts2BsubA.add( it12 );
            }
            else if( delta == ans4 ){
                Item it21 = ts2BsubA.pollLast();
                ts1A.add(it21);
                ts1BsubA.add(it21);

                Item it02 = ts0b.pollFirst();
                ts0a.remove( it02 );
                ts2BsubA.add( it02 );
            }
            else MLE();

            if(!( ts0a.size() == ts0b.size() )) MLE();
            if(!( ts1A.size() == ts1BsubA.size() )) MLE();
            if(!( ts0a.size() + ts1A.size() + ts2BsubA.size() == n )) MLE();
            if( ans1==inf && ans2 == inf ) MLE();
        }

        out.println( ans );
        Integer[] answer = new Integer[n];
        long ANS = 0;
        for( Item it : ts0a     ) answer[it.id] = 0;
        for( Item it : ts1A     ) { answer[it.id] = 1; ANS += it.a; }
        for( Item it : ts2BsubA ) { answer[it.id] = 2; ANS += it.b; }
        for( Integer val : answer ) out.print(val);
        out.println();
        if( ans != ANS ) MLE();
    }


}