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 tmp[600010];
long long sum[2400010];
int num[2400010];
void update(int root) {
  sum[root] = sum[root << 1] + sum[root << 1 | 1];
  num[root] = num[root << 1] + num[root << 1 | 1];
  return;
}
void add(int root, int l, int r, int x, int y) {
  if (l == r) {
    num[root] += y;
    sum[root] += y * tmp[x];
    return;
  }
  int mid = (l + r) >> 1;
  if (x <= mid)
    add(root << 1, l, mid, x, y);
  else
    add(root << 1 | 1, mid + 1, r, x, y);
  update(root);
  return;
}
long long query(int root, int l, int r, int k) {
  if (l == r) return (long long)k * tmp[l];
  int mid = (l + r) >> 1;
  if (num[root << 1] >= k)
    return query(root << 1, l, mid, k);
  else
    return sum[root << 1] +
           query(root << 1 | 1, mid + 1, r, k - num[root << 1]);
}
struct Level {
  int a, b, id;
} l[300010];
bool cmp(Level a, Level b) { return a.b < b.b; }
struct Point {
  int a, b;
} p[300010];
bool cmp2(Point a, Point b) { return a.a < b.a; }
int x[300010];
int main() {
  int n, w;
  scanf("%d %d", &n, &w);
  int W = w;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &l[i].a, &l[i].b);
    l[i].id = i;
    tmp[i * 2 - 1] = l[i].a;
    tmp[i * 2] = l[i].b - l[i].a;
  }
  sort(tmp + 1, tmp + n * 2 + 1);
  sort(l + 1, l + n + 1, cmp);
  long long ans = 1e18, pos = 0;
  for (int i = 1; i <= n; i++)
    add(1, 1, n * 2, lower_bound(tmp + 1, tmp + n * 2 + 1, l[i].a) - tmp, 1);
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    long long lstans = ans;
    if (w < 0) break;
    if (w == 0) ans = min(ans, sum);
    if (w <= n) ans = min(ans, sum + query(1, 1, n * 2, w));
    if (lstans > ans) pos = i - 1;
    add(1, 1, n * 2, lower_bound(tmp + 1, tmp + n * 2 + 1, l[i].a) - tmp, -1);
    add(1, 1, n * 2,
        lower_bound(tmp + 1, tmp + n * 2 + 1, l[i].b - l[i].a) - tmp, 1);
    sum += l[i].a;
    w--;
  }
  long long lstans = ans;
  if (w > 0) ans = min(ans, sum + query(1, 1, n * 2, w));
  if (lstans > ans) pos = n;
  printf("%I64d\n", ans);
  for (int i = 1; i <= n; i++) {
    if (i <= pos) {
      x[l[i].id] = 1;
      p[i] = (Point){l[i].b - l[i].a, l[i].id};
    } else {
      x[l[i].id] = 0;
      p[i] = (Point){l[i].a, l[i].id};
    }
  }
  sort(p + 1, p + n + 1, cmp2);
  for (int i = 1; i <= W - pos; i++) x[p[i].b]++;
  for (int i = 1; i <= n; i++) printf("%d", x[i]);
  return 0;
}