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;
struct ii {
  int first;
  int second;
  int i;
  ii(int a = 0, int b = 0) {
    first = a;
    second = b;
  }
  bool operator<(const ii &o) const {
    return first == o.first ? second < o.second : first < o.first;
  }
};
ii l[300010];
int n, w;
long long A[300010];
int tk[300010];
bool cmp(ii a, ii b) { return a.second - a.first > b.second - b.first; }
long long cost(int n1, int n2, long long r = -1) {
  priority_queue<int> q;
  long long sum = 0;
  long long res = 1e15;
  int I = -1;
  for (int i = (0); i < (n + 1); i++) {
    if (int(q.size()) == n1)
      A[i] = sum;
    else
      A[i] = 1e15;
    if (n1 == 0) continue;
    if (i != n) {
      if (int(q.size()) == n1 && q.top() > l[i].first) {
        sum -= q.top();
        q.pop();
      }
      if (int(q.size()) < n1) {
        sum += l[i].first;
        q.push(l[i].first);
      }
    }
  }
  q = priority_queue<int>();
  sum = 0;
  for (int i = n; i >= 0; i--) {
    if (int(q.size()) == n2) {
      res = min(res, A[i] + sum);
      if (A[i] + sum == r) {
        I = i;
        goto tkc;
      }
    }
    if (n2 == 0) continue;
    if (i != 0) {
      if (int(q.size()) == n2 && q.top() > l[i - 1].second) {
        sum -= q.top();
        q.pop();
      }
      if (int(q.size()) < n2) {
        sum += l[i - 1].second;
        q.push(l[i - 1].second);
      }
    }
  }
  return res;
tkc:;
  priority_queue<ii> oq;
  for (int i = (0); i < (n + 1); i++) {
    if (i == I) {
      while (!oq.empty()) {
        tk[l[oq.top().second].i] = 1;
        oq.pop();
      }
      break;
    }
    if (n1 == 0) continue;
    if (i != n) {
      if (int(oq.size()) == n1 && oq.top().first > l[i].first) oq.pop();
      if (int(oq.size()) < n1) oq.push(ii(l[i].first, i));
    }
  }
  for (int i = n; i >= 0; i--) {
    if (i == I) {
      while (!oq.empty()) {
        tk[l[oq.top().second].i] = 2;
        oq.pop();
      }
    }
    if (n2 == 0) continue;
    if (i != 0) {
      if (int(oq.size()) == n2 && oq.top().first > l[i - 1].second) oq.pop();
      if (int(oq.size()) < n2) oq.push(ii(l[i - 1].second, i - 1));
    }
  }
  return -1;
}
int main() {
  scanf("%d %d", &n, &w);
  for (int i = (0); i < (n); i++) {
    scanf("%d %d", &l[i].first, &l[i].second);
    l[i].i = i;
  }
  if (n == 1) {
    if (w == 1)
      printf("%d\n1\n", l[0].first);
    else
      printf("%d\n2\n", l[0].second);
    return 0;
  }
  sort(l, l + n, cmp);
  vector<int> m;
  for (int i = (0); i < (n + 1); i++) {
    if ((w - i) % 2 == 0 && i + 2 * (n - i) >= w) m.push_back(i);
  }
  pair<long long, int> res(1e15, -1);
  int s = 0, e = int(m.size()) - 1;
  while (s <= e) {
    int md1 = s + (e - s) / 3, md2 = s + 2 * (e - s) / 3;
    long long v1 = cost(m[md1], (w - m[md1]) / 2);
    res = min(res, make_pair(v1, m[md1]));
    if (s == e)
      break;
    else if (md1 == md2)
      md2++;
    long long v2 = cost(m[md2], (w - m[md2]) / 2);
    res = min(res, make_pair(v2, m[md2]));
    if (v1 <= v2) {
      e = md2 - 1;
    } else {
      s = md1 + 1;
    }
  }
  printf("%lld\n", res.first);
  cost(res.second, (w - res.second) / 2, res.first);
  for (int i = (0); i < (n); i++) {
    printf("%d", tk[i]);
  }
  printf("\n");
}