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;
#pragma comment(linker, "/STACK:200000000")
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
const int NMAX = 310000;
set<pair<int, int> > q[3][3];
int a[NMAX], b[NMAX], n, w, c[NMAX][3];
long long s;
char st[NMAX];
void out() {
  puts(st);
  exit(0);
}
void add(int id) {
  int cur = st[id] - '0';
  s += c[id][cur];
  for (int i = 0; i < (int)(3); i++) {
    if (i == cur) continue;
    q[cur][i].insert(make_pair(c[id][i] - c[id][cur], id));
  }
}
void erase(int id) {
  int cur = st[id] - '0';
  s -= c[id][cur];
  for (int i = 0; i < (int)(3); i++) {
    if (i == cur) continue;
    q[cur][i].erase(make_pair(c[id][i] - c[id][cur], id));
  }
}
void perf(int st1, int st2) {
  int id = q[st1][st2].begin()->second;
  erase(id);
  st[id] = st2 + '0';
  add(id);
}
bool can2(int f1, int t1, int f2, int t2) {
  if (q[f1][t1].empty()) return false;
  int id1 = q[f1][t1].begin()->second;
  int v1 = q[f1][t1].begin()->first;
  erase(id1);
  if (q[f2][t2].empty()) {
    add(id1);
    return false;
  }
  int id2 = q[f2][t2].begin()->second;
  int v2 = q[f2][t2].begin()->first;
  erase(id2);
  if (v1 + v2 >= 0) {
    add(id1);
    add(id2);
    return false;
  }
  st[id1] = t1 + '0';
  add(id1);
  st[id2] = t2 + '0';
  add(id2);
  return true;
}
bool can3(int f1, int t1, int f2, int t2, int f3, int t3) {
  if (q[f1][t1].empty()) return false;
  int id1 = q[f1][t1].begin()->second;
  long long v1 = q[f1][t1].begin()->first;
  erase(id1);
  if (q[f2][t2].empty()) {
    add(id1);
    return false;
  }
  int id2 = q[f2][t2].begin()->second;
  long long v2 = q[f2][t2].begin()->first;
  erase(id2);
  if (q[f3][t3].empty()) {
    add(id1);
    add(id2);
    return false;
  }
  int id3 = q[f3][t3].begin()->second;
  long long v3 = q[f3][t3].begin()->first;
  erase(id3);
  if (v1 + v2 + v3 >= 0) {
    add(id1);
    add(id2);
    add(id3);
    return false;
  }
  st[id1] = t1 + '0';
  add(id1);
  st[id2] = t2 + '0';
  add(id2);
  st[id3] = t3 + '0';
  add(id3);
  return true;
}
long long solve(long long ans = -1) {
  for (int i = 0; i < (int)(3); i++)
    for (int j = 0; j < (int)(3); j++) q[i][j].clear();
  for (int i = 0; i < (int)(n); i++) st[i] = '0';
  for (int i = 0; i < (int)(n); i++) add(i);
  s = 0;
  int left = w;
  while (left) {
    if (left >= 2 && q[0][2].size()) {
      perf(0, 2);
      left -= 2;
    } else if (left >= 1 && q[0][1].size()) {
      perf(0, 1);
      left--;
    }
  }
  if (left) throw;
  long long res = s;
  if (s == ans) out();
  bool change = true;
  while (change) {
    change = false;
    change |= can2(0, 1, 1, 0);
    change |= can2(0, 1, 2, 1);
    change |= can2(1, 2, 2, 1);
    change |= can2(1, 2, 1, 0);
    change |= can2(0, 2, 2, 0);
    change |= can3(0, 2, 2, 1, 2, 1);
    change |= can3(0, 2, 1, 0, 2, 1);
    change |= can3(0, 2, 1, 0, 1, 0);
    change |= can3(2, 0, 1, 2, 1, 2);
    change |= can3(2, 0, 0, 1, 1, 2);
    change |= can3(2, 0, 0, 1, 0, 1);
    if (res == ans) out();
    res = min(res, s);
  }
  return res;
}
int main() {
  cin >> n >> w;
  for (int i = 0; i < (int)(n); i++) {
    scanf("%d%d", &a[i], &b[i]);
    c[i][0] = 0;
    c[i][1] = a[i];
    c[i][2] = b[i];
  }
  long long ans = solve();
  cout << ans << endl;
  solve(ans);
  return 0;
}