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, m;
int b, p;
int c[300010], a1[300010], b1[300010];
long long ans;
priority_queue<pair<int, pair<int, pair<int, int> > > > q;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &b, &p);
    p -= b;
    a1[i] = b;
    b1[i] = p;
    q.push(make_pair(-(b * 2), make_pair(-p, make_pair(1, i))));
    q.push(make_pair(-(p + b), make_pair(-p, make_pair(2, i))));
  }
  int ha = 0;
  while (ha < m - 1) {
    int h = -q.top().first;
    int d = q.top().second.second.first;
    int num = q.top().second.second.second;
    int p = -q.top().second.first;
    if (c[num] == 2 || (ha == m - 1 && d == 2 && c[num] == 0)) {
      q.pop();
      continue;
    }
    if (d == 1) {
      c[num] = 1;
      h /= 2;
      ans = ans + h;
      ha++;
      q.push(make_pair(-(p * 2), make_pair(-p, make_pair(3, num))));
    }
    if (d == 2) {
      if (c[num] == 1) {
        q.pop();
        continue;
      } else {
        ha += 2;
        ans = ans + h;
      }
      c[num] = 2;
    }
    if (d == 3) {
      ans = ans + (h / 2);
      ha++;
      c[num] = 2;
    }
    q.pop();
  }
  if (ha == m - 1) {
    int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0;
    int q1, q2, q3, q4;
    q1 = q2 = q3 = q4 = 2000000001;
    for (int i = 1; i <= n; i++)
      if (c[i] == 0) {
        if (!c5 || a1[c5] + b1[c5] > a1[i] + b1[i]) c5 = i;
        if (!c3 || a1[c3] > a1[i]) c3 = i;
      } else if (c[i] == 1) {
        if (!c1 || a1[c1] < a1[i]) c1 = i;
        if (!c4 || b1[c4] > b1[i]) c4 = i;
      } else if (c[i] == 2)
        if (!c2 || b1[c2] < b1[i]) c2 = i;
    if (c3) q1 = a1[c3];
    if (c4) q2 = b1[c4];
    if (c1 && c5) q3 = a1[c5] + b1[c5] - a1[c1];
    if (c2 && c5) q4 = a1[c5] + b1[c5] - b1[c2];
    if (q1 <= q2 && q1 <= q3 && q1 <= q4) {
      ans += a1[c3];
      c[c3] = 1;
    } else if (q2 <= q1 && q2 <= q3 && q2 <= q4) {
      ans += b1[c4];
      c[c4] = 2;
    } else if (q3 <= q2 && q3 <= q1 && q3 <= q4) {
      ans += a1[c5] + b1[c5] - a1[c1];
      c[c5] = 2;
      c[c1] = 0;
    } else if (q4 <= q2 && q4 <= q3 && q4 <= q1) {
      ans += a1[c5] + b1[c5] - b1[c2];
      c[c5] = 2;
      c[c2] = 1;
    }
  }
  printf("%lld\n", ans);
  for (int i = 1; i <= n; i++) putchar(c[i] + 48);
  return 0;
}