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;
const int INF = 1e9 + 7;
const int maxn = 300005;
int n, mk, a[maxn], b[maxn], lst, used[maxn];
int isget[maxn][2], ansget[maxn][2];
bool vis[maxn][3];
inline int read() {
  int res = 0, f_f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f_f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    res = (res << 3) + (res << 1) + (ch - '0'), ch = getchar();
  return res * f_f;
}
struct AS {
  int x, tp, w;
  AS() {}
  AS(int x, int tp, int w) : x(x), tp(tp), w(w) {}
  bool operator<(const AS B) const { return w > B.w; }
};
priority_queue<AS> Q;
inline long long solve(int m, int d) {
  memset(vis, 0, sizeof(vis));
  memset(isget, 0, sizeof(isget));
  memset(used, 0, sizeof(used));
  while (!Q.empty()) Q.pop();
  for (int i = 1; i <= n; i++) {
    Q.push(AS(i, 0, a[i] << 1));
    Q.push(AS(i, 2, a[i] + b[i]));
  }
  long long ans = 0;
  while (1) {
    if (!m) break;
    AS u = Q.top();
    Q.pop();
    if (vis[u.x][u.tp]) continue;
    if (u.tp == 0) {
      ans += u.w >> 1;
      vis[u.x][0] = true;
      vis[u.x][2] = true;
      m--, used[u.x] = 1, isget[u.x][0] = 1;
      Q.push(AS(u.x, 1, b[u.x] << 1));
    } else if (u.tp == 1) {
      ans += u.w >> 1;
      vis[u.x][1] = true;
      m--, used[u.x] = 2, isget[u.x][1] = 1;
    } else {
      if (m == 1) continue;
      ans += u.w;
      vis[u.x][0] = true;
      vis[u.x][1] = true;
      vis[u.x][2] = true;
      m -= 2, used[u.x] = 2;
      isget[u.x][0] = 1, isget[u.x][1] = 1;
    }
  }
  if (!d) return ans;
  lst = -INF;
  int cur = 0, tp = 0;
  for (int i = 1; i <= n; i++) {
    if (used[i] == 1 && lst < a[i]) {
      isget[cur][tp] = 1, isget[i][0] = 0;
      lst = a[i], cur = i, tp = 0;
    }
    if (used[i] == 2 && lst < b[i]) {
      isget[cur][tp] = 1, isget[i][1] = 0;
      lst = b[i], cur = i, tp = 1;
    }
  }
  return ans - lst;
}
int main() {
  n = read(), mk = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read(), b[i] = read();
    b[i] -= a[i];
    Q.push(AS(i, 0, a[i] << 1));
    Q.push(AS(i, 2, a[i] + b[i]));
  }
  long long ans = solve(mk, 0);
  memcpy(ansget, isget, sizeof(isget));
  if ((n << 1) > mk) {
    long long cur = solve(mk + 1, 1);
    if (cur < ans) {
      ans = cur;
      memcpy(ansget, isget, sizeof(isget));
    }
  }
  printf("%lld\n", ans);
  for (int i = 1; i <= n; i++) {
    if (ansget[i][1])
      printf("2");
    else if (ansget[i][0])
      printf("1");
    else
      printf("0");
  }
  printf("\n");
  return 0;
}