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 dat {
  int x, id;
  bool operator<(dat const &T) const { return x == T.x ? id < T.id : x > T.x; }
};
struct pq {
  int n;
  char v[300005];
  priority_queue<dat> q;
  dat begin() {
    while (1) {
      dat t = q.top();
      if (v[t.id]) return t;
      q.pop();
    }
  }
  void insert(dat x) {
    if (v[x.id]) return;
    v[x.id] = 1;
    ++n;
    q.push(x);
  }
  void erase(int x) {
    v[x] = 0;
    --n;
  }
};
int n, m;
int a[300005], b[300005], v[300005];
pq S1, S2, Q1, Q2, R;
int c2[5], c3[5];
long long c1[5], ret = 0;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (n); i++) {
    scanf("%d%d", &a[i], &b[i]);
    S1.insert((dat){a[i], i});
    S2.insert((dat){b[i], i});
    v[i] = 0;
  }
  for (int i = (0); i < (m); i++) {
    for (int j = (0); j < (4); j++) c1[j] = (1LL << 60);
    if (S1.n) {
      c1[0] = S1.begin().x;
      c2[0] = S1.begin().id;
    }
    if (Q1.n) {
      c1[1] = Q1.begin().x;
      c2[1] = Q1.begin().id;
    }
    if (S2.n && Q2.n) {
      c1[2] = S2.begin().x + Q2.begin().x;
      c2[2] = S2.begin().id;
      c3[2] = Q2.begin().id;
    }
    if (S2.n && R.n) {
      c1[3] = S2.begin().x + R.begin().x;
      c2[3] = S2.begin().id;
      c3[3] = R.begin().id;
    }
    long long mn = (1LL << 60);
    for (int j = (0); j < (4); j++) mn = min(mn, c1[j]);
    ret += mn;
    if (c1[0] == mn) {
      int id = c2[0];
      S1.erase(id);
      S2.erase(id);
      Q1.insert((dat){b[id] - a[id], id});
      Q2.insert((dat){-a[id], id});
      v[id] = 1;
    } else if (c1[1] == mn) {
      int id = c2[1];
      Q1.erase(id);
      Q2.erase(id);
      R.insert((dat){a[id] - b[id], id});
      v[id] = 2;
    } else if (c1[2] == mn) {
      int id = c2[2];
      S1.erase(id);
      S2.erase(id);
      R.insert((dat){a[id] - b[id], id});
      v[id] = 2;
      id = c3[2];
      S1.insert((dat){a[id], id});
      S2.insert((dat){b[id], id});
      Q1.erase(id);
      Q2.erase(id);
      v[id] = 0;
    } else {
      int id = c2[3];
      S1.erase(id);
      S2.erase(id);
      R.insert((dat){a[id] - b[id], id});
      v[id] = 2;
      id = c3[3];
      R.erase(id);
      Q1.insert((dat){b[id] - a[id], id});
      Q2.insert((dat){-a[id], id});
      v[id] = 1;
    }
  }
  printf("%I64d\n", ret);
  for (int i = (0); i < (n); i++) printf("%d", v[i]);
  return 0;
}