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;
vector<long long> disc;
struct BIT {
  long long tree[300011 << 1][2];
  int n;
  int shift(int x) { return x & (-x); }
  void update(int index, long long cnt, long long w) {
    if (index <= 0) return;
    while (index <= n) {
      tree[index][0] += cnt;
      tree[index][1] += w;
      index += shift(index);
    }
  }
  pair<long long, long long> getans(int index) {
    long long v1 = 0, v2 = 0;
    while (index > 0) {
      v1 += tree[index][0], v2 += tree[index][1];
      index -= shift(index);
    }
    return make_pair(v1, v2);
  }
  int getindex(long long w) {
    int low = 0, high = n;
    int idx = n;
    while (low <= high) {
      int mid = low + ((high - low) >> 1);
      if (getans(mid).first >= w) {
        idx = mid;
        high = mid - 1;
      } else {
        low = mid + 1;
      }
    }
    return idx;
  }
};
BIT tree;
struct level {
  long long a, b;
  int id;
  bool operator<(level other) const { return b < other.b; }
};
level arr[300011];
long long inc[300011];
long long tmp[300011 << 1];
bool se1[300011], se2[300011];
bool visited[300011];
int main() {
  int i, n, j = 1;
  long long w;
  long long curr = 0, ans = 0, prefix = 0;
  scanf("%d%lld", &n, &w);
  for (i = 1; i <= n; i++) {
    scanf("%lld%lld", &arr[i].a, &arr[i].b);
    arr[i].id = i;
    tmp[j++] = arr[i].a;
    tmp[j++] = arr[i].b - arr[i].a;
    ans += arr[i].b;
  }
  sort(tmp + 1, tmp + 2 * n + 1);
  sort(arr + 1, arr + n + 1);
  disc.push_back(0);
  for (i = 1; i <= 2 * n; i++) {
    if (i == 1 || tmp[i] != tmp[i - 1]) disc.push_back(tmp[i]);
  }
  tree.n = (int)disc.size();
  for (i = 1; i <= n; i++) {
    int index = lower_bound(disc.begin(), disc.end(), arr[i].a) - disc.begin();
    tree.update(index, 1, arr[i].a);
    inc[i] = arr[i].b - arr[i].a;
  }
  int findex = n;
  for (i = 0; i <= n; i++) {
    int index = lower_bound(disc.begin(), disc.end(), inc[i]) - disc.begin();
    tree.update(index, 1, inc[i]);
    index = lower_bound(disc.begin(), disc.end(), arr[i].a) - disc.begin();
    tree.update(index, -1, -arr[i].a);
    prefix += arr[i].a;
    if (w - i <= n) {
      index = tree.getindex(w - i);
      auto p = tree.getans(index);
      curr = p.second - (p.first - (w - i)) * disc[index];
      if (curr + prefix < ans) {
        ans = curr + prefix;
        findex = i;
      }
    }
  }
  printf("%lld\n", ans);
  priority_queue<pair<long long, int>, vector<pair<long long, int>>,
                 greater<pair<long long, int>>>
      q;
  curr = 0;
  for (i = 1; i <= findex; i++) {
    curr++;
    q.push(make_pair(inc[i], arr[i].id));
    se1[arr[i].id] = true;
    visited[arr[i].id] = true;
  }
  for (i = findex + 1; i <= n; i++) {
    q.push(make_pair(arr[i].a, arr[i].id));
  }
  while (curr < w && !q.empty()) {
    int index = q.top().second;
    q.pop();
    if (visited[index]) {
      se1[index] = false;
      se2[index] = true;
    } else {
      se1[index] = true;
    }
    curr++;
  }
  for (i = 1; i <= n; i++) {
    if (se1[i]) {
      printf("1");
    } else if (se2[i]) {
      printf("2");
    } else {
      printf("0");
    }
  }
  printf("\n");
  return 0;
}