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>
#pragma GCC optimize(2)
inline int read() {
  int x = 0;
  register char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    ;
  for (; isdigit(ch); x = x * 10 + (ch ^ 48), ch = getchar())
    ;
  return x;
}
const int MAXN = 3e5 + 10;
const long long INFLL = 1e18;
int n, m;
int a[MAXN], b[MAXN], vis[MAXN];
inline long long solve(int m) {
  long long sum = 0;
  memset(vis, 0, sizeof(vis));
  std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >,
                      std::greater<std::pair<int, int> > >
      NtoA, AtoB, BtoA, AtoN, NtoB;
  for (int i = 1; i <= n; ++i)
    NtoA.push(std::make_pair(a[i], i)), NtoB.push(std::make_pair(b[i], i));
  while (m-- > 0) {
    while (!NtoA.empty() && vis[NtoA.top().second] != 0) NtoA.pop();
    while (!AtoB.empty() && vis[AtoB.top().second] != 1) AtoB.pop();
    while (!BtoA.empty() && vis[BtoA.top().second] != 2) BtoA.pop();
    while (!AtoN.empty() && vis[AtoN.top().second] != 1) AtoN.pop();
    while (!NtoB.empty() && vis[NtoB.top().second] != 0) NtoB.pop();
    long long sum1 = !NtoA.empty() ? NtoA.top().first : INFLL;
    long long sum2 = !AtoB.empty() ? AtoB.top().first : INFLL;
    long long sum3 = !BtoA.empty() && !NtoB.empty()
                         ? BtoA.top().first + NtoB.top().first
                         : INFLL;
    long long sum4 = !AtoN.empty() && !NtoB.empty()
                         ? AtoN.top().first + NtoB.top().first
                         : INFLL;
    long long tmp = std::min(std::min(sum1, sum2), std::min(sum3, sum4));
    sum += tmp;
    if (tmp == sum1) {
      std::pair<int, int> now = NtoA.top();
      NtoA.pop();
      int id = now.second;
      vis[id] = 1;
      AtoB.push(std::make_pair(b[id] - a[id], id)),
          AtoN.push(std::make_pair(-a[id], id));
    } else if (tmp == sum2) {
      std::pair<int, int> now = AtoB.top();
      AtoB.pop();
      int id = now.second;
      vis[id] = 2;
      BtoA.push(std::make_pair(a[id] - b[id], id));
    } else if (tmp == sum3) {
      std::pair<int, int> now1 = BtoA.top(), now2 = NtoB.top();
      BtoA.pop(), NtoB.pop();
      int id1 = now1.second, id2 = now2.second;
      vis[id1] = 1, vis[id2] = 2;
      AtoB.push(std::make_pair(b[id1] - a[id1], id1)),
          AtoN.push(std::make_pair(-a[id1], id1));
      BtoA.push(std::make_pair(a[id2] - b[id2], id2));
    } else {
      std::pair<int, int> now1 = AtoN.top(), now2 = NtoB.top();
      AtoN.pop(), NtoB.pop();
      int id1 = now1.second, id2 = now2.second;
      vis[id1] = 0, vis[id2] = 2;
      NtoA.push(std::make_pair(a[id1], id1)),
          NtoB.push(std::make_pair(b[id1], id1));
      BtoA.push(std::make_pair(a[id2] - b[id2], id2));
    }
  }
  return sum;
}
int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) *(a + i) = read(), *(b + i) = read();
  long long ans1 = solve(m), ans2 = m < 2 * n ? solve(m + 1) : INFLL;
  if (ans1 < ans2)
    printf("%lld\n", ans1), solve(m);
  else
    printf("%lld\n", ans2), solve(m + 1);
  for (int i = 1; i <= n; ++i) putchar(vis[i] | 48);
  putchar('\n');
  return 0;
}