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;
long long n, m, ans;
long long a[300010], b[300010], pos[300010];
struct arr {
  long long sum, num;
  bool operator<(const arr &t) const { return sum > t.sum; }
};
priority_queue<arr> q1, q2, q3, q4, q5;
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) scanf("%lld%lld", &a[i], &b[i]);
  for (long long i = 1; i <= n; i++) {
    pos[i] = 0;
    arr now;
    now.num = i;
    now.sum = a[i];
    q1.push(now);
    now.num = i;
    now.sum = b[i];
    q4.push(now);
  }
  for (long long i = 1; i <= m; i++) {
    long long sum1 = 1e18;
    while (!q1.empty()) {
      arr now;
      now = q1.top();
      if (pos[now.num] != 0) {
        q1.pop();
        continue;
      }
      sum1 = now.sum;
      break;
    }
    long long sum2 = 1e18;
    while (!q2.empty()) {
      arr now;
      now = q2.top();
      if (pos[now.num] != 1) {
        q2.pop();
        continue;
      }
      sum2 = now.sum;
      break;
    }
    long long tmp;
    while (!q4.empty()) {
      arr now;
      now = q4.top();
      if (pos[now.num] != 0) {
        q4.pop();
        continue;
      }
      tmp = now.sum;
      break;
    }
    long long sum3 = 1e18;
    long long sum4 = 1e18;
    if (!q4.empty()) {
      while (!q3.empty()) {
        arr now;
        now = q3.top();
        if (pos[now.num] != 2) {
          q3.pop();
          continue;
        }
        sum3 = now.sum + tmp;
        break;
      }
      while (!q5.empty()) {
        arr now;
        now = q5.top();
        if (pos[now.num] != 1) {
          q5.pop();
          continue;
        }
        sum4 = now.sum + tmp;
        break;
      }
    }
    long long key = 1;
    long long mn = sum1;
    if (mn > sum2) mn = sum2, key = 2;
    if (mn > sum3) mn = sum3, key = 3;
    if (mn > sum4) mn = sum4, key = 4;
    ans += mn;
    if (key == 1) {
      arr now;
      now = q1.top();
      q1.pop();
      pos[now.num] = 1;
      arr haha;
      haha.num = now.num;
      haha.sum = b[now.num] - a[now.num];
      q2.push(haha);
      haha.num = now.num;
      haha.sum = -a[now.num];
      q5.push(haha);
    }
    if (key == 2) {
      arr now;
      now = q2.top();
      q2.pop();
      pos[now.num] = 2;
      arr haha;
      haha.num = now.num;
      haha.sum = -b[now.num] + a[now.num];
      q3.push(haha);
    }
    if (key == 3) {
      arr now, haha;
      now = q3.top();
      q3.pop();
      pos[now.num] = 1;
      haha.num = now.num;
      haha.sum = -a[now.num];
      q5.push(haha);
      haha.num = now.num;
      haha.sum = b[now.num] - a[now.num];
      q2.push(haha);
      now = q4.top();
      q4.pop();
      pos[now.num] = 2;
      haha.num = now.num;
      haha.sum = -b[now.num] + a[now.num];
      q3.push(haha);
    }
    if (key == 4) {
      arr now, haha, now1;
      now = q5.top();
      q5.pop();
      pos[now.num] = 0;
      haha.num = now.num;
      haha.sum = a[now.num];
      q1.push(haha);
      now1 = q4.top();
      q4.pop();
      haha.num = now.num;
      haha.sum = b[now.num];
      q4.push(haha);
      pos[now1.num] = 2;
      haha.num = now1.num;
      haha.sum = -b[now1.num] + a[now1.num];
      q3.push(haha);
    }
  }
  printf("%lld\n", ans);
  for (long long i = 1; i <= n; i++) printf("%lld", pos[i]);
  return 0;
}