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;
int n, w;
int a[300500], b[300500];
long long sum1[2 * 300500];
long long sum2[2 * 300500];
int add2[2 * 300500];
int cnt[300500];
vector<int> t2;
vector<pair<int, int> > t1;
class C1 {
 public:
  bool operator()(int x, int y) {
    return ((b[x] - a[x]) > (b[y] - a[y]) ||
            ((b[x] - a[x]) == (b[y] - a[y]) && x < y));
  }
};
class C2 {
 public:
  bool operator()(int x, int y) {
    return ((a[x] < a[y]) || (a[x] == a[y] && x < y));
  }
};
bool cmp_fst(int x, int y) {
  return (b[x] < b[y] || (b[x] == b[y] && a[x] < a[y]) ||
          (b[x] == b[y] && a[x] == a[y] && x < y));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> w;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    if (b[i] - a[i] >= a[i]) {
      t1.push_back(make_pair(a[i], i));
      t1.push_back(make_pair(b[i] - a[i], i));
    } else {
      t2.push_back(i);
    }
  }
  sort(t1.begin(), t1.end());
  sum1[0] = 0LL;
  int pos1 = 0;
  for (vector<pair<int, int> >::iterator it = t1.begin(); it != t1.end();
       ++it, ++pos1) {
    sum1[pos1 + 1] = sum1[pos1] + it->first;
  }
  sort(t2.begin(), t2.end(), cmp_fst);
  set<int, C1> st1;
  set<int, C2> st2(t2.begin(), t2.end());
  int pos2 = 0;
  sum2[0] = 0LL;
  for (vector<int>::iterator add = t2.begin(); add != t2.end(); ++add, ++pos2) {
    int cur_v = *add;
    sum2[pos2 * 2 + 2] = sum2[pos2 * 2] + b[cur_v];
    sum2[pos2 * 2 + 1] = sum2[pos2 * 2] + a[*(st2.begin())];
    add2[pos2 * 2 + 1] = *(st2.begin());
    st2.erase(cur_v);
    st1.insert(cur_v);
    int min_v = *(st1.begin());
    if (sum2[pos2 * 2 + 1] > sum2[pos2 * 2 + 2] - b[min_v] + a[min_v]) {
      sum2[pos2 * 2 + 1] = sum2[pos2 * 2 + 2] - (b[min_v] - a[min_v]);
      add2[pos2 * 2 + 1] = -min_v - 1;
    }
  }
  long long res = LLONG_MAX;
  int ind = -1;
  for (int i = 0; i <= 2 * pos2; ++i) {
    int df = w - i;
    if (df >= 0 && df <= pos1 && res > sum1[df] + sum2[i]) {
      res = sum1[df] + sum2[i];
      ind = i;
    }
  }
  int df = w - ind;
  for (int i = 0; i < df; ++i) {
    cnt[t1[i].second]++;
  }
  for (int i = 0; (i * 2) < (ind & -2); ++i) {
    cnt[t2[i]] += 2;
  }
  if (ind % 2 == 1) {
    if (add2[ind] >= 0) {
      ++cnt[add2[ind]];
    } else {
      cnt[t2[ind / 2]] += 2;
      --cnt[-add2[ind] - 1];
    }
  }
  cout << res << '\n';
  for (int i = 0; i < n; ++i) {
    cout << cnt[i];
  }
  cout << '\n';
  return 0;
}