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>
#pragma comment(linker, "/STACK:128777216")
const int null = 0;
using namespace std;
template <class T>
int size(const T &a) {
  return int(a.size());
}
template <class T>
T abs(const T &a) {
  return (a < 0 ? -a : a);
}
template <class T>
T sqr(const T &a) {
  return a * a;
}
const int max_n = 700000;
struct Level {
  int a, b;
  int k;
  int t;
  int id;
  void scan() {
    static int cid = 0;
    id = cid++;
    scanf("%d %d", &a, &b);
  }
  void invert() {
    a = b - a;
    a = -a;
    b = -b;
  }
  void init() {
    if (a + a < b) {
      k = a + a;
      t = 1;
    } else {
      k = b;
      t = 2;
    }
  }
  bool operator<(const Level &l) const { return k < l.k; }
} a[max_n], b[max_n];
int r[max_n];
long long solve(int n, int w) {
  int m = 0;
  for (int i = 0; i < n; i++) {
    if (a[i].t == 1) {
      b[m] = a[i];
      b[m + 1] = a[i];
      b[m + 1].k = (a[i].b - a[i].a) * 2;
      b[m + 1].a = (a[i].b - a[i].a);
      m += 2;
    } else {
      b[m++] = a[i];
    }
  }
  sort(b, b + m);
  Level *a = b;
  long long res = 0;
  for (int i = 0; w; i++) {
    if (a[i].t <= w) {
      r[a[i].id] += a[i].t;
      w -= a[i].t;
      res += a[i].k / (3 - a[i].t);
    } else {
      int mi = i;
      long long mn = a[i].a;
      for (int j = i + 1; j < m; j++) {
        if (a[j].a < mn) {
          mn = a[j].a;
          mi = j;
        }
      }
      int mj = -1;
      long long mn2 = mn;
      for (int j = 0; j < i; j++) {
        long long cur;
        if (a[j].t == 1) {
          cur = a[i].b - a[j].a;
        } else {
          cur = a[i].b - a[j].b + a[j].a;
        }
        if (cur < mn2) {
          mn2 = cur;
          mj = j;
        }
      }
      res += min(mn, mn2);
      if (mn <= mn2) {
        r[a[mi].id] += 1;
      } else {
        r[a[i].id] += 2;
        r[a[mj].id]--;
      }
      break;
    }
  }
  return res;
}
int main() {
  int n, w;
  scanf("%d %d", &n, &w);
  for (int i = 0; i < n; i++) {
    a[i].scan();
  }
  long long res = 0;
  bool inv = false;
  if (w > n) {
    inv = true;
    w = n * 2 - w;
    for (int i = 0; i < n; i++) {
      res += a[i].b;
      a[i].invert();
    }
  }
  for (int i = 0; i < n; i++) {
    a[i].init();
  }
  res += solve(n, w);
  if (inv) {
    for (int i = 0; i < n; i++) {
      r[i] = 2 - r[i];
    }
  }
  cout << res << endl;
  for (int i = 0; i < n; i++) {
    printf("%d", r[i]);
  }
  return 0;
}