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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int n, ans[300001], w, times[300001];
pair<int, int> cost[300001];
long long answ;
struct one {
  int id, cost;
  bool operator()(one a, one b) {
    if (a.cost < b.cost) return true;
    if (b.cost < a.cost) return false;
    return (a.id < b.id);
  }
};
set<one, one> my_set_one;
struct two {
  int id, cost;
  bool operator()(two a, two b) {
    if (a.cost < b.cost) return true;
    if (b.cost < a.cost) return false;
    return (a.id < b.id);
  }
};
set<two, two> my_set_two;
int main() {
  scanf("%d %d", &n, &w);
  for (int i = 0; i < n; i++) {
    int f, s;
    scanf("%d %d", &f, &s);
    cost[i].first = f;
    cost[i].second = s;
    one new_one;
    new_one.cost = f;
    new_one.id = i;
    my_set_one.insert(new_one);
    two new_two;
    new_two.cost = s;
    new_two.id = i;
    my_set_two.insert(new_two);
  }
  int cnt = 0;
  while (cnt < w) {
    if (cnt + 2 <= w) {
      set<one, one>::iterator it = (my_set_one.begin());
      one f_one_p = *it;
      ++it;
      one s_one_p;
      if (it == my_set_one.end()) {
        s_one_p.cost = 2e9 + 1;
        s_one_p.id = -1;
      } else
        s_one_p = *it;
      set<two, two>::iterator it_t = (my_set_two.begin());
      two two_p;
      if (it_t != my_set_two.end())
        two_p = *it_t;
      else {
        two_p.cost = -1;
        two_p.id = -1;
      }
      if (two_p.cost == -1 || (f_one_p.cost + s_one_p.cost < two_p.cost)) {
        answ += f_one_p.cost;
        cnt++;
        my_set_one.erase(f_one_p);
        two d;
        d.cost = cost[f_one_p.id].second;
        d.id = f_one_p.id;
        my_set_two.erase(d);
        if (++times[f_one_p.id] == 1) {
          one new_one_f;
          new_one_f.id = f_one_p.id;
          new_one_f.cost = cost[new_one_f.id].second - cost[new_one_f.id].first;
          my_set_one.insert(new_one_f);
        }
      } else {
        answ += cost[two_p.id].first;
        cnt++;
        times[two_p.id]++;
        one d;
        d.cost = cost[two_p.id].first;
        d.id = two_p.id;
        my_set_one.erase(d);
        my_set_two.erase(two_p);
        one new_one;
        new_one.cost = cost[two_p.id].second - cost[two_p.id].first;
        new_one.id = two_p.id;
        my_set_one.insert(new_one);
      }
    } else {
      one p_one;
      p_one = *my_set_one.begin();
      answ += p_one.cost;
      times[p_one.id]++;
      cnt++;
    }
  }
  printf("%I64d\n", answ);
  for (int i = 0; i < n; i++) {
    printf("%d", times[i]);
  }
  return 0;
}