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 = int(1e9) + 7;
const long long inf64 = (long long)inf * inf;
pair<pair<int, int>, int> s2[300005];
long long bit[2][300005];
int bitvec[2][300005], n, w;
char output[300005];
void setValue(int t, int idx, int v) {
  int delta = v - bitvec[t][idx];
  bitvec[t][idx] = v;
  for (int j = idx; j < n; j = (j | (j + 1))) {
    bit[t][j] += delta;
  }
}
long long getSum(int t, int idx) {
  long long ans = 0;
  for (int j = idx; j >= 0; j = (j & (j + 1)) - 1) {
    ans += bit[t][j];
  }
  return ans;
}
void setState(int idx, bool on) {
  int mult = (on ? 1 : 0);
  setValue(0, idx, mult);
  setValue(1, idx, mult * s2[idx].first.first);
}
int lowbound(int cnt) {
  int lo = 0, hi = n - 1;
  while (lo < hi) {
    int mid = (lo + hi) >> 1, res = 2 * (int)getSum(0, mid);
    if (res < cnt) {
      lo = mid + 1;
    } else {
      hi = mid;
    }
  }
  return lo;
}
long long solve(long long best = inf64) {
  priority_queue<pair<pair<int, int>, int>, vector<pair<pair<int, int>, int> >,
                 greater<pair<pair<int, int>, int> > >
      pq;
  memset(bit, 0, sizeof bit);
  memset(bitvec, 0, sizeof bitvec);
  for (int i = 0; i < (n); ++i) {
    pair<int, int> cur(s2[i].first.second, s2[i].first.first);
    setState(i, true);
    pq.push(make_pair(pair<int, int>(cur.first, cur.second - cur.first), i));
  }
  int curs = 0;
  long long curcost = 0, localbest = inf64;
  for (int steps = 0; steps < (w); ++steps) {
    pair<int, int> next = pq.top().first;
    int idx = pq.top().second;
    int p = lowbound(w - curs);
    int stars = 2 * (int)getSum(0, p);
    if (stars >= w - curs) {
      localbest = min(curcost + getSum(1, p), localbest);
      if (localbest == best) goto PrintSub;
    }
    pq.pop();
    ++curs, curcost += next.first;
    if (next.second < inf) setState(idx, false);
    pq.push(make_pair(pair<int, int>(next.second, inf), idx));
  }
  localbest = min(localbest, curcost);
  if (localbest == best) {
  PrintSub:
    vector<bool> tookone(n, false);
    while (!pq.empty()) {
      pair<int, int> next = pq.top().first;
      int idx = pq.top().second;
      pq.pop();
      if (next.first != inf && next.second == inf) tookone[idx] = true;
    }
    int twolim = (curs == w ? -1 : lowbound(w - curs));
    int sum = 0;
    memset(output, 0, sizeof output);
    for (int i = 0; i < (n); ++i) {
      int pos = s2[i].second, got;
      if (bitvec[0][i] == 1) {
        got = (i <= twolim ? 2 : 0);
      } else {
        got = (tookone[i] ? 1 : 2);
      }
      output[pos] = got + '0';
      sum += got;
    }
    printf("%s\n", output);
    assert(sum >= w);
  }
  return localbest;
}
int main() {
  while (~scanf("%d %d", &n, &w)) {
    for (int i = 0; i < (n); ++i) {
      scanf("%d %d", &s2[i].first.second, &s2[i].first.first);
      s2[i].second = i;
    }
    sort(s2, s2 + n);
    long long best = solve();
    cout << best << endl;
    solve(best);
  }
  return 0;
}