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 long long inf = 1LL << 60;
int n, w, L;
vector<int> a, b;
vector<int> num;
const int N = 1200010;
int cnt[N << 2];
long long sum[N << 2];
void pushUp(int idx) {
  cnt[idx] = cnt[idx << 1] + cnt[idx << 1 | 1];
  sum[idx] = sum[idx << 1] + sum[idx << 1 | 1];
}
void init_seg(int l, int r, int idx) {
  if (l == r) {
    cnt[idx] = 0;
    sum[idx] = 0;
    return;
  }
  int mid = l + r >> 1;
  init_seg(l, mid, idx << 1);
  init_seg(mid + 1, r, idx << 1 | 1);
  pushUp(idx);
}
void update_seg(int l, int r, int idx, int ki, int delta) {
  if (l == r) {
    cnt[idx] += delta;
    sum[idx] += delta * num[ki];
    return;
  }
  int mid = l + r >> 1;
  if (ki <= mid)
    update_seg(l, mid, idx << 1, ki, delta);
  else
    update_seg(mid + 1, r, idx << 1 | 1, ki, delta);
  pushUp(idx);
}
long long query_seg(int l, int r, int idx, int k) {
  if (k <= 0) return 0;
  if (cnt[idx] == k) {
    return sum[idx];
  }
  if (l == r) {
    return sum[idx] / cnt[idx] * k;
  }
  long long ret = 0;
  int mid = l + r >> 1;
  return query_seg(l, mid, idx << 1, min(k, cnt[idx << 1])) +
         query_seg(mid + 1, r, idx << 1 | 1, k - min(k, cnt[idx << 1]));
}
int findIdx(int key) {
  int l = 0, r = L - 1;
  if (num[r] == key) return r;
  while (l + 1 < r) {
    int mid = l + r >> 1;
    if (num[mid] <= key)
      l = mid;
    else
      r = mid;
  }
  return l;
}
void formatOutput(int l, vector<pair<int, pair<int, int>>>& ba) {
  string ans(n, '0');
  for (int i = 0; i < l + 1; i++) {
    ans[ba[i].second.second] = '1';
  }
  priority_queue<pair<int, int>, vector<pair<int, int>>,
                 greater<pair<int, int>>>
      pq;
  for (int i = 0; i < n; i++) {
    if (i < l + 1) {
      pq.push(pair<int, int>(ba[i].first - ba[i].second.first,
                             ba[i].second.second));
    } else {
      pq.push(pair<int, int>(ba[i].second.first, ba[i].second.second));
    }
  }
  for (int i = 0; i < w - l - 1; i++) {
    pair<int, int> p = pq.top();
    pq.pop();
    ans[p.second]++;
  }
  printf("%s\n", ans.c_str());
}
long long calcAllOne() {
  long long ret = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < w; i++) {
    ret += a[i];
  }
  return ret;
}
void solve(int ncase) {
  scanf("%d%d", &n, &w);
  a.assign(n, 0);
  b.assign(n, 0);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  num.assign(3 * n, 0);
  vector<pair<int, pair<int, int>>> ba(n);
  for (int i = 0; i < n; i++) {
    num[3 * i + 0] = a[i];
    num[3 * i + 1] = b[i];
    num[3 * i + 2] = b[i] - a[i];
    ba[i] = pair<int, pair<int, int>>(b[i], pair<int, int>(a[i], i));
  }
  sort(num.begin(), num.end());
  num.erase(unique(num.begin(), num.end()), num.end());
  L = num.size();
  init_seg(0, L - 1, 1);
  sort(ba.begin(), ba.end());
  vector<long long> suma(n);
  for (int i = 0; i < n; i++) {
    if (i == 0)
      suma[i] = ba[i].second.first;
    else
      suma[i] = suma[i - 1] + ba[i].second.first;
    update_seg(0, L - 1, 1, findIdx(ba[i].second.first), 1);
  }
  long long ans = inf, ansi = -1;
  if (w <= n) {
    ans = calcAllOne();
  }
  for (int l = 0; l < n && l + 1 <= w; l++) {
    update_seg(0, L - 1, 1, findIdx(ba[l].second.first), -1);
    update_seg(0, L - 1, 1, findIdx(ba[l].first - ba[l].second.first), 1);
    if (l + 1 + n < w) continue;
    long long ret = query_seg(0, L - 1, 1, w - l - 1);
    if (ret + suma[l] < ans) {
      ans = ret + suma[l];
      ansi = l;
    }
  }
  printf("%I64d\n", ans);
  formatOutput(ansi, ba);
}
int main() {
  int T = 1;
  int ncase = 0;
  while (T--) {
    solve(++ncase);
  }
}