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 MAXN = 2000000;
int n, w;
int n1, n2;
pair<long long, int> lis1[MAXN];
pair<long long, int> lis2[MAXN];
long long a[MAXN], b[MAXN];
long long ans;
int rec[MAXN];
int temp[MAXN];
void check() {
  long long v = 0;
  for (int i = 0; i < n; ++i) {
    if (temp[i] == 1) {
      v += a[i];
    } else if (temp[i] == 2) {
      v += b[i];
    }
  }
  if (v < ans) {
    ans = v;
    for (int i = 0; i < n; ++i) {
      rec[i] = temp[i];
    }
  }
}
long long cost1[MAXN];
int mi2[MAXN];
int main() {
  cin >> n >> w;
  n1 = n2 = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i] >> b[i];
    if (a[i] * 2LL > b[i]) {
      lis2[n2++] = make_pair(b[i], i);
    } else {
      lis1[n1++] = make_pair(a[i], i);
      lis1[n1++] = make_pair(b[i] - a[i], i);
    }
  }
  sort(lis1, lis1 + n1);
  sort(lis2, lis2 + n2);
  if (n2 > 0) {
    mi2[n2 - 1] = lis2[n2 - 1].second;
  }
  for (int i = n2 - 2; i >= 0; --i) {
    mi2[i] = mi2[i + 1];
    if (a[lis2[i].second] < a[mi2[i]]) {
      mi2[i] = lis2[i].second;
    }
  }
  ans = 1LL << 60;
  cost1[0] = 0;
  for (int i = 0; i < n1; ++i) {
    cost1[i + 1] = cost1[i] + lis1[i].first;
  }
  long long ans1 = 1LL << 60;
  long long cost2 = 0;
  int rec1 = -1;
  int rec2Minus = -1, rec2Minus1;
  int rec2Plus = -1, rec2Plus1;
  long long ma2Minus = -1LL << 60;
  int maMinusRec;
  long long temp1;
  for (int i = 0; i < n2 + 1; ++i) {
    if (0 <= w - i * 2 && w - i * 2 <= n1) {
      temp1 = cost2 + cost1[w - i * 2];
      if (temp1 < ans1) {
        ans1 = temp1;
        rec1 = i;
      }
    }
    if (i < n2 && i * 2 + 1 <= w && i * 2 + 1 + n1 >= w) {
      temp1 = cost2 + cost1[w - i * 2 - 1] + a[mi2[i]];
      if (temp1 < ans1) {
        ans1 = temp1;
        rec2Plus = i;
        rec2Plus1 = mi2[i];
      }
    }
    if (i < n2) {
      cost2 += lis2[i].first;
      long long dif = b[lis2[i].second] - a[lis2[i].second];
      if (dif > ma2Minus) {
        ma2Minus = dif;
        maMinusRec = lis2[i].second;
      }
      if (i * 2 + 1 <= w && i * 2 + 1 + n1 >= w) {
        temp1 = cost2 - ma2Minus + cost1[w - i * 2 - 1];
        if (temp1 < ans1) {
          ans1 = temp1;
          rec2Minus = i;
          rec2Minus1 = maMinusRec;
        }
      }
    }
  }
  if (rec1 != -1) {
    memset(temp, 0, sizeof(temp));
    for (int i = 0; i < rec1; ++i) {
      temp[lis2[i].second] = 2;
    }
    for (int i = 0; i < w - rec1 * 2; ++i) {
      temp[lis1[i].second]++;
    }
    check();
  }
  if (rec2Plus != -1) {
    memset(temp, 0, sizeof(temp));
    for (int i = 0; i < rec2Plus; ++i) {
      temp[lis2[i].second] = 2;
    }
    temp[rec2Plus1]++;
    for (int i = 0; i < w - rec2Plus * 2 - 1; ++i) {
      temp[lis1[i].second]++;
    }
    check();
  }
  if (rec2Minus != -1) {
    memset(temp, 0, sizeof(temp));
    for (int i = 0; i <= rec2Minus; ++i) {
      temp[lis2[i].second] = 2;
    }
    temp[rec2Minus1]--;
    for (int i = 0; i < w - rec2Minus * 2 - 1; ++i) {
      temp[lis1[i].second]++;
    }
    check();
  }
  cout << ans << "\n";
  for (int i = 0; i < n; ++i) {
    cout << rec[i];
  }
  cout << "\n";
  return 0;
}