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>
template <class t>
inline void read(t &s) {
  s = 0;
  register long long f = 1;
  register char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (isdigit(c)) s = (s << 3) + (s << 1) + (c ^ 48), c = getchar();
  s *= f;
  return;
}
template <class t, class... A>
inline void read(t &x, A &...a) {
  read(x);
  read(a...);
}
template <class t>
inline void write(t x) {
  if (x < 0) putchar('-'), x = -x;
  long long buf[21], top = 0;
  while (x) buf[++top] = x % 10, x /= 10;
  if (!top) buf[++top] = 0;
  while (top) putchar(buf[top--] ^ '0');
  return;
}
inline void setIn(std::string s) {
  freopen(s.c_str(), "r", stdin);
  return;
}
inline void setOut(std::string s) {
  freopen(s.c_str(), "w", stdout);
  return;
}
inline void setIO(std::string s = "") {
  setIn(s + ".in");
  setOut(s + ".out");
  return;
}
template <class t>
inline bool ckmin(t &x, t y) {
  if (x > y) {
    x = y;
    return 1;
  }
  return 0;
}
template <class t>
inline bool ckmax(t &x, t y) {
  if (x < y) {
    x = y;
    return 1;
  }
  return 0;
}
inline long long lowbit(long long x) { return x & (-x); }
const long long MaxN = 3e5 + 50;
long long n, W;
long long opt[MaxN], a[MaxN], b[MaxN];
struct Fraxinus {
  long long C, k1, k2;
  inline long long val(long long x) const { return k1 * a[x] + k2 * b[x]; }
  struct Node {
    long long x, k1, k2;
    Node(long long y, long long d1, long long d2) { x = y, k1 = d1, k2 = d2; }
    Node() { x = k1 = k2 = 0; }
    inline long long val(long long x) const { return k1 * a[x] + k2 * b[x]; }
    inline bool operator<(const Node &nt) const { return val(nt.x) < val(x); }
  };
  std::priority_queue<Node> Q;
  inline void work() {
    while (!Q.empty() && opt[Q.top().x] != C) Q.pop();
  }
  inline void push(long long x) { Q.push(Node(x, k1, k2)); }
  inline long long ok() {
    work();
    return !Q.empty();
  }
  inline long long top() {
    work();
    return Q.top().x;
  }
  inline long long vtp() {
    work();
    return val(Q.top().x);
  }
} q[6];
inline void to0(long long x) { opt[x] = 0, q[1].push(x), q[4].push(x); }
inline void to1(long long x) { opt[x] = 1, q[2].push(x), q[3].push(x); }
inline void to2(long long x) { opt[x] = 2, q[5].push(x); }
signed main(void) {
  read(n, W);
  q[2].C = q[3].C = 1, q[5].C = 2;
  q[1].k1 = 1, q[2].k1 = -1, q[2].k2 = 1, q[3].k1 = -1, q[4].k2 = 1,
  q[5].k1 = 1, q[5].k2 = -1;
  for (long long i = 1; i <= n; ++i) read(a[i], b[i]);
  for (long long i = 1; i <= n; ++i) to0(i);
  register long long ans = 0;
  while (W--) {
    register long long cur = 0, mx = 1e18;
    if (q[1].ok() && ckmin(mx, q[1].vtp())) cur = 1;
    if (q[2].ok() && ckmin(mx, q[2].vtp())) cur = 2;
    if (q[3].ok() && q[4].ok() && ckmin(mx, q[3].vtp() + q[4].vtp())) cur = 3;
    if (q[4].ok() && q[5].ok() && ckmin(mx, q[4].vtp() + q[5].vtp())) cur = 4;
    ans += mx;
    if (cur == 1)
      to1(q[1].top());
    else if (cur == 2)
      to2(q[2].top());
    else if (cur == 3)
      to2(q[4].top()), to0(q[3].top());
    else
      to1(q[5].top()), to2(q[4].top());
  }
  write(ans), std::puts("");
  for (long long i = 1; i <= n; ++i) write(opt[i]);
  std::puts("");
  return 0;
}