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 Level {
  int one, two, id;
  pair<int, int> getOneKey() { return make_pair(one, 2 * id); }
  pair<int, int> getTwoKey() { return make_pair(two - one, 2 * id + 1); }
  bool operator<(const Level &a) const { return two < a.two; }
};
class FenwickTree {
  vector<pair<int, int> > keys;
  vector<long long> sum;
  vector<int> cnt;
  int n;
  void update(int x, int delta) {
    for (int i = x; i < n; i |= i + 1) {
      sum[i] += delta * keys[x].first;
      cnt[i] += delta;
    }
  }
  pair<long long, int> get(int x) {
    pair<long long, int> res;
    for (int i = x; i >= 0; i -= ~i & (i + 1)) {
      res.first += sum[i];
      res.second += cnt[i];
    }
    return res;
  }

 public:
  FenwickTree(vector<pair<int, int> > key) {
    sort(key.begin(), key.end());
    n = key.size();
    sum.assign(n, 0);
    cnt.assign(n, 0);
    keys = key;
  }
  void update(const pair<int, int> &key, int delta) {
    int pos = lower_bound(keys.begin(), keys.end(), key) - keys.begin();
    assert(keys.at(pos) == key);
    update(pos, delta);
  }
  long long minElementSum(int m) {
    if (m <= 0) return 0;
    if (m > get(n - 1).second) return (long long)1e18;
    int low = 0, high = n - 1;
    while (low < high) {
      int mid = (low + high) / 2;
      if (get(mid).second >= m)
        high = mid;
      else
        low = mid + 1;
    }
    return get(low).first;
  }
};
const int N = (int)3e5, INF = (int)2e9;
Level level[N];
int n, w;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> w;
  for (int i = 0; i < n; ++i) {
    cin >> level[i].one >> level[i].two;
    level[i].id = i;
  }
  sort(level, level + n);
  vector<pair<int, int> > value;
  for (int i = 0; i < n; ++i) {
    value.push_back(level[i].getOneKey());
    value.push_back(level[i].getTwoKey());
  }
  FenwickTree tree(value);
  for (int i = 0; i < n; ++i) tree.update(level[i].getOneKey(), 1);
  long long bestCost = (long long)1e18;
  long long firstCost = 0;
  int bestPrefix = -1;
  for (int prefix = 0; prefix <= n; ++prefix) {
    long long secondCost = tree.minElementSum(w - prefix);
    if (firstCost + secondCost < bestCost) {
      bestCost = firstCost + secondCost;
      bestPrefix = prefix;
    }
    if (prefix < n) {
      tree.update(level[prefix].getOneKey(), -1);
      tree.update(level[prefix].getTwoKey(), 1);
      firstCost += level[prefix].one;
    }
  }
  string res(n, '0');
  for (int i = 0; i < bestPrefix; ++i) res[level[i].id] = '1';
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      q;
  for (int i = 0; i < bestPrefix; ++i) q.push(level[i].getTwoKey());
  for (int i = bestPrefix; i < n; ++i) q.push(level[i].getOneKey());
  for (int i = 0; i < w - bestPrefix; ++i) {
    ++res[q.top().second / 2];
    q.pop();
  }
  cout << bestCost << '\n';
  cout << res << '\n';
  return 0;
}