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;
const int N = 3e5 + 5;
const long long inf = 1e17;
int a[N], b[N], n, w;
int ct[N];
struct data {
  long long d;
  int u;
  inline bool operator<(const data& rhs) const {
    return d == rhs.d ? u < rhs.u : d > rhs.d;
  }
  inline bool operator==(const data& rhs) const {
    return d == rhs.d && u == rhs.u;
  }
};
struct structure {
  priority_queue<data> p, q;
  inline void push(const data& h) { p.push(h); }
  inline void erase(const data& h) { q.push(h); }
  inline bool empty() { return p.size() == q.size(); }
  inline data top() {
    while (!p.empty() && !q.empty() && p.top() == q.top()) p.pop(), q.pop();
    return p.top();
  }
  inline void pop() {
    while (!p.empty() && !q.empty() && p.top() == q.top()) p.pop(), q.pop();
    p.pop();
  }
} _02, _01, _bak;
long long ans;
priority_queue<data> X, Y;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> w;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    _02.push((data){b[i], i});
    _01.push((data){a[i], i});
  }
  while (w--) {
    long long _1 = (_01.empty()) ? inf : (_01.top().d),
              _2 = (_02.empty() || _bak.empty()) ? (inf)
                                                 : (_02.top().d + _bak.top().d);
    if (_1 <= _2) {
      int u = _01.top().u;
      ans += _1;
      _01.pop();
      ++ct[u];
      if (ct[u] == 1) {
        _01.push((data){b[u] - a[u], u});
        _02.erase((data){b[u], u});
      }
      _bak.push((data){-_1, u});
    } else {
      int u0 = _02.top().u, u1 = _bak.top().u;
      ans += _2;
      ct[u0] += 2;
      _02.pop();
      _bak.pop();
      _01.erase((data){a[u0], u0});
      _bak.push((data){-b[u0] + a[u0], u0});
      --ct[u1];
      if (ct[u1] == 1) {
        _bak.push((data){-a[u1], u1});
        _01.push((data){b[u1] - a[u1], u1});
      } else
        _01.erase((data){b[u1] - a[u1], u1}), _01.push((data){a[u1], u1}),
            _02.push((data){b[u1], u1});
    }
  }
  for (int i = 1; i <= n; ++i)
    if (ct[i] == 1)
      X.push((data){b[i] - a[i], i});
    else if (ct[i] == 2)
      Y.push((data){-b[i] + a[i], i});
  while (!X.empty() && !Y.empty() && X.top().d + Y.top().d < 0) {
    ans += X.top().d + Y.top().d;
    int u1 = X.top().u;
    ++ct[u1];
    int u2 = Y.top().u;
    --ct[u2];
    X.pop(), Y.pop();
    X.push((data){b[u2] - a[u2], u2});
    Y.push((data){-b[u1] + a[u1], u1});
  }
  long long res = 0;
  for (int i = 1; i <= n; ++i)
    if (ct[i] < 0 || ct[i] > 2)
      return 1;
    else
      res += ct[i] == 2 ? b[i] : (ct[i] == 1 ? a[i] : 0);
  cout << res << '\n';
  for (int i = 1; i <= n; ++i) cout << ct[i];
  return 0;
}