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 Node {
  int x, y, id;
  Node() {}
  Node(int x, int y, int id) : x(x), y(y), id(id) {}
};
bool operator<(const Node &a, const Node &b) { return a.y < b.y; }
struct Node2 {
  int val, id, t;
  Node2() { val = id = t = 0; }
  Node2(int val, int id, int t) : val(val), id(id), t(t) {}
};
bool operator<(const Node2 &a, const Node2 &b) {
  if (a.val != b.val) return a.val < b.val;
  if (a.id != b.id) return a.id < b.id;
  return a.t < b.t;
}
struct FT {
  long long T[(1 << 20)];
  FT() {}
  void clear() { memset(T, 0, sizeof(T)); }
  void update(int pos, long long val) {
    while (pos < (1 << 20)) {
      T[pos] += val;
      pos += (pos & -pos);
    }
  }
  long long query(int pos) {
    long long sum = 0;
    while (pos) {
      sum += T[pos];
      pos -= (pos & -pos);
    }
    return sum;
  }
} bit0, bit1;
int getKth(int k) {
  int lo = 0, hi = (1 << 20) - 1;
  while (hi - lo > 1) {
    int med = (lo + hi) >> 1;
    if (bit0.query(med) >= k)
      hi = med;
    else
      lo = med;
  }
  return hi;
}
int getId(vector<Node2> &v, Node2 value) {
  return lower_bound(v.begin(), v.end(), value) - v.begin();
}
void impr(vector<int> &v) {
  for (int i = 0; i < ((int)(v).size()); ++i) printf("%d", v[i]);
  puts("");
}
int main() {
  int n, k, x, y;
  while (scanf("%d", &n) == 1) {
    scanf("%d", &k);
    bit0.clear(), bit1.clear();
    vector<Node> V;
    vector<Node2> vec(1);
    for (int i = 0; i < n; ++i) {
      scanf("%d", &x), scanf("%d", &y);
      V.push_back(Node(x, y, i + 1));
      vec.push_back(Node2(x, i + 1, 0));
      vec.push_back(Node2(y - x, i + 1, 1));
    }
    sort(V.begin(), V.end());
    sort(vec.begin(), vec.end());
    for (int i = 0; i < n; ++i) {
      bit0.update(getId(vec, Node2(V[i].x, V[i].id, 0)), 1);
      bit1.update(getId(vec, Node2(V[i].x, V[i].id, 0)), V[i].x);
    }
    int last = -1;
    long long ans = LLONG_MAX, sum = 0;
    if (n >= k) {
      int ind = getKth(k);
      ans = bit1.query(ind);
      last = 0;
    }
    for (int i = 0; i < n; ++i) {
      bit0.update(getId(vec, Node2(V[i].x, V[i].id, 0)), -1);
      bit1.update(getId(vec, Node2(V[i].x, V[i].id, 0)), -V[i].x);
      int val = V[i].y - V[i].x;
      bit0.update(getId(vec, Node2(V[i].y - V[i].x, V[i].id, 1)), 1);
      bit1.update(getId(vec, Node2(V[i].y - V[i].x, V[i].id, 1)),
                  V[i].y - V[i].x);
      sum += V[i].x;
      if (n + i + 1 >= k && (i + 1) <= k) {
        int ind = getKth(k - (i + 1));
        long long opt = bit1.query(ind) + sum;
        if (ans > opt) {
          ans = opt;
          last = i + 1;
        }
      }
    }
    cout << ans << '\n';
    bit0.clear(), bit1.clear();
    for (int i = 0; i < n; ++i) {
      bit0.update(getId(vec, Node2(V[i].x, V[i].id, 0)), 1);
      bit1.update(getId(vec, Node2(V[i].x, V[i].id, 0)), V[i].x);
    }
    vector<int> sol(n);
    if (last == 0) {
      int ind = getKth(k);
      for (int i = 1; i <= ind; ++i)
        if (bit0.query(i) - bit0.query(i - 1)) {
          sol[vec[i].id - 1] = 1;
        }
      impr(sol);
      continue;
    }
    if (n >= k) {
      int ind = getKth(k);
      ans = bit1.query(ind);
    }
    for (int i = 0; i < n; ++i) {
      bit0.update(getId(vec, Node2(V[i].x, V[i].id, 0)), -1);
      bit1.update(getId(vec, Node2(V[i].x, V[i].id, 0)), -V[i].x);
      int val = V[i].y - V[i].x;
      bit0.update(getId(vec, Node2(V[i].y - V[i].x, V[i].id, 1)), 1);
      bit1.update(getId(vec, Node2(V[i].y - V[i].x, V[i].id, 1)),
                  V[i].y - V[i].x);
      sol[V[i].id - 1] = 1;
      if (n + i + 1 >= k && (i + 1) <= k && i + 1 == last) {
        int ind = getKth(k - (i + 1));
        for (int j = 1; j <= ind; ++j) {
          if (bit0.query(j) - bit0.query(j - 1)) {
            if (vec[j].t == 0)
              sol[vec[j].id - 1] = max(sol[vec[j].id - 1], 1);
            else
              sol[vec[j].id - 1] = max(sol[vec[j].id - 1], 2);
          }
        }
        break;
      }
    }
    impr(sol);
  }
}