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>
void gi(long long int &x) {
  char ch = getchar();
  x = 0;
  while (ch < '0' || ch > '9') ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - 48, ch = getchar();
}
void pi(long long int x) {
  if (x > 9) pi(x / 10);
  putchar(x % 10 + 48);
}
void swap(long long int &x, long long int &y) {
  long long int t = x;
  x = y;
  y = t;
}
long long int A[602020], B[602020];
long long int S[602020], T[602020], b[602020][2], sb[602020];
long long int M[602020], N[602020], M2[602020], N2[602020];
long long int n, p, ls, lt;
void init1() {
  long long int i;
  gi(n);
  gi(p);
  for (i = 1; i <= n; i++) {
    gi(A[i]), gi(B[i]);
    if (B[i] - A[i] > A[i]) {
      S[++ls] = A[i];
      b[ls][0] = i;
      b[ls][1] = 1;
      S[++ls] = B[i] - A[i];
      b[ls][0] = i;
      b[ls][1] = 2;
    } else
      T[++lt] = i;
  }
}
void sorts(long long int l, long long int r) {
  long long int i = l, j = r, mid = S[rand() % (r - l + 1) + l], t;
  while (i <= j) {
    for (; S[i] < mid; i++)
      ;
    for (; S[j] > mid; j--)
      ;
    if (i <= j) {
      t = S[i];
      S[i] = S[j];
      S[j] = t;
      t = b[i][0];
      b[i][0] = b[j][0];
      b[j][0] = t;
      t = b[i][1];
      b[i][1] = b[j][1];
      b[j][1] = t;
      i++, j--;
    }
  }
  if (l < j) sorts(l, j);
  if (i < r) sorts(i, r);
}
void sortt(long long int l, long long int r) {
  long long int i = l, j = r, mid = B[T[rand() % (r - l + 1) + l]], t;
  while (i <= j) {
    for (; B[T[i]] < mid; i++)
      ;
    for (; B[T[j]] > mid; j--)
      ;
    if (i <= j) t = T[i], T[i] = T[j], T[j] = t, i++, j--;
  }
  if (l < j) sortt(l, j);
  if (i < r) sortt(i, r);
}
void prepare() {
  init1();
  if (ls > 1) sorts(1, ls);
  if (lt > 1) sortt(1, lt);
  for (long long int i = 1; i <= lt; i++)
    if (i == 1 || B[T[i]] - A[T[i]] > M[i - 1])
      M[i] = B[T[i]] - A[T[i]], N[i] = i;
    else
      M[i] = M[i - 1], N[i] = N[i - 1];
  for (long long int i = 1; i <= ls; i++) S[i] += S[i - 1];
  for (long long int i = 1; i <= lt; i++) sb[i] = sb[i - 1] + B[T[i]];
  for (long long int i = lt; i; i--)
    if (i == lt || A[T[i]] < M2[i + 1])
      M2[i] = A[T[i]], N2[i] = i;
    else
      M2[i] = M2[i + 1], N2[i] = N2[i + 1];
}
long long int ask(long long int Q) {
  long long int x, y;
  if (((p - Q + 1) >> 1) > lt) return 1ll << 62;
  if ((p - Q) & 1) {
    x = sb[(p - Q + 1) >> 1] - M[(p - Q + 1) >> 1] + S[Q];
    y = sb[(p - Q - 1) >> 1] + M2[(p - Q + 1) >> 1] + S[Q];
    if (x < y)
      return x;
    else
      return y;
  } else
    return sb[(p - Q) >> 1] + S[Q];
}
long long int ans[602020];
void create(long long int Q) {
  long long int i;
  for (i = 1; i <= Q; i++)
    if (b[i][1] > ans[b[i][0]]) ans[b[i][0]] = b[i][1];
  if (~(p - Q) & 1) {
    for (i = 1; i <= ((p - Q) >> 1); i++) ans[T[i]] = 2;
  } else {
    long long int x, y;
    x = sb[(p - Q + 1) >> 1] - M[(p - Q + 1) >> 1] + S[Q];
    y = sb[(p - Q - 1) >> 1] + M2[(p - Q + 1) >> 1] + S[Q];
    for (i = 1; i <= ((p - Q + 1) >> 1); i++) ans[T[i]] = 2;
    if (x < y)
      ans[T[N[(p - Q + 1) >> 1]]] = 1;
    else
      ans[T[(p - Q + 1) >> 1]] = 0, ans[T[N2[(p - Q + 1) >> 1]]] = 1;
  }
  for (i = 1; i <= n; i++) putchar(ans[i] + 48);
}
int main() {
  long long int i, a = 1ll << 61, b, c;
  prepare();
  for (i = 0; i <= ls && i <= p; i++) {
    c = ask(i);
    if (c < a) a = c, b = i;
  }
  pi(a);
  putchar('\n');
  create(b);
  return 0;
}