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;
template <typename T>
T mabs(const T &a) {
  return a < 0 ? -a : a;
}
set<pair<int, int> > avSum;
set<pair<int, int> > avA, usedA;
set<pair<int, int> > avB, usedB;
int A[300100], B[300100];
void addSum(int i) {
  avSum.erase(pair<int, int>(A[i] + B[i], i));
  avA.erase(pair<int, int>(A[i], i));
  usedB.insert(pair<int, int>(B[i], i));
}
void run() {
  int n, w;
  cin >> n >> w;
  for (int i = (0), ei = (n); i < ei; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    b -= a;
    A[i] = a;
    B[i] = b;
    avSum.insert(pair<int, int>(a + b, i));
    avA.insert(pair<int, int>(a, i));
  }
  long long res = 0;
  for (int i = (0), ei = (w); i < ei; i++) {
    set<pair<int, int> >::iterator sumIt = avSum.begin();
    set<pair<int, int> >::iterator aIt = avA.begin();
    set<pair<int, int> >::iterator bIt = avB.begin();
    set<pair<int, int> >::iterator it;
    long long newSum = 1e18;
    int move = -1;
    if (aIt != avA.end()) {
      long long here = res;
      here += aIt->first;
      if (here < newSum) {
        newSum = here;
        move = 0;
      }
    }
    if (bIt != avB.end()) {
      long long here = res;
      here += bIt->first;
      if (here < newSum) {
        newSum = here;
        move = 1;
      }
    }
    if (usedB.size() > 0 && sumIt != avSum.end()) {
      long long here = res;
      it = usedB.end();
      --it;
      here += sumIt->first - it->first;
      if (here < newSum) {
        newSum = here;
        move = 2;
      }
    }
    if (usedA.size() > 0 && sumIt != avSum.end()) {
      long long here = res;
      it = usedA.end();
      --it;
      here += sumIt->first - it->first;
      if (here < newSum) {
        newSum = here;
        move = 3;
      }
    }
    res = newSum;
    if (move == 0) {
      int ind = aIt->second;
      avA.erase(aIt);
      usedA.insert(pair<int, int>(A[ind], ind));
      avB.insert(pair<int, int>(B[ind], ind));
      avSum.erase(pair<int, int>(A[ind] + B[ind], ind));
    }
    if (move == 1) {
      int ind = bIt->second;
      avB.erase(bIt);
      usedB.insert(pair<int, int>(B[ind], ind));
      usedA.erase(pair<int, int>(A[ind], ind));
    }
    if (move == 2) {
      it = usedB.end();
      --it;
      int indb = it->second;
      avB.insert(pair<int, int>(B[indb], indb));
      usedB.erase(pair<int, int>(B[indb], indb));
      usedA.insert(pair<int, int>(A[indb], indb));
      addSum(sumIt->second);
    }
    if (move == 3) {
      it = usedA.end();
      --it;
      int inda = it->second;
      avA.insert(pair<int, int>(A[inda], inda));
      usedA.erase(pair<int, int>(A[inda], inda));
      avB.erase(pair<int, int>(B[inda], inda));
      avSum.insert(pair<int, int>(A[inda] + B[inda], inda));
      addSum(sumIt->second);
    }
  }
  char Res[300100] = {0};
  memset(Res, '0', n);
  for (auto p : usedA) Res[p.second] = '1';
  for (auto p : usedB) Res[p.second] = '2';
  cout << res << endl;
  puts(Res);
}
int main() {
  run();
  return 0;
}