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>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
const long long inf = 1000000000000000000LL;
const int maxN = 310000;
int a[maxN], b[maxN];
int n, m;
int order[maxN];
int pA[maxN], posA[maxN];
int pB[maxN], posB[maxN];
bool cmp(int x, int y) { return a[x] - b[x] < a[y] - b[y]; }
bool cmpA(int x, int y) { return a[x] < a[y]; }
bool cmpB(int x, int y) { return b[x] < b[y]; }
long long fA[maxN], fB[maxN];
int cntA[maxN], cntB[maxN];
void updateF(long long f[], int k, long long delta) {
  for (int i = k; i < maxN; i |= (i + 1)) {
    f[i] += delta;
  }
}
long long getF(long long f[], int k) {
  long long res = 0;
  for (int i = k; i >= 0; i = (i & (i + 1)) - 1) {
    res += f[i];
  }
  return res;
}
void updateC(int f[], int k, int delta) {
  for (int i = k; i < maxN; i |= (i + 1)) {
    f[i] += delta;
  }
}
int getC(int f[], int k) {
  int res = 0;
  for (int i = k; i >= 0; i = (i & (i + 1)) - 1) {
    res += f[i];
  }
  return res;
}
int getPos(int cnt[], int k) {
  int left_bound = 0, right_bound = n - 1;
  while (right_bound - left_bound > 1) {
    int middle = (left_bound + right_bound) / 2;
    if (getC(cnt, middle) >= k) {
      right_bound = middle;
    } else {
      left_bound = middle;
    }
  }
  if (getC(cnt, left_bound) == k) {
    return left_bound;
  } else {
    return right_bound;
  }
}
long long calc(int ones, int twos) {
  return getF(fA, getPos(cntA, ones)) + getF(fB, getPos(cntB, twos));
}
int res[maxN];
bool check(int x, int y, int k) {
  int posR = getPos(cntA, x + 2 * k);
  int posL = getPos(cntA, x + 2 * k - 1);
  long long sumA = getF(fA, posR) - getF(fA, posL - 1);
  int posB = getPos(cntB, y + 1 - k);
  long long sumB = getF(fB, posB) - getF(fB, posB - 1);
  return sumA < sumB;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &a[i], &b[i]);
    pA[i] = i;
    pB[i] = i;
    order[i] = i;
  }
  sort(order, order + n, cmp);
  sort(pA, pA + n, cmpA);
  sort(pB, pB + n, cmpB);
  for (int i = 0; i < n; ++i) {
    posA[pA[i]] = i;
    posB[pB[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    updateC(cntB, posB[order[i]], +1);
    updateF(fB, posB[order[i]], b[order[i]]);
  }
  long long best = inf;
  int split = -1;
  int x = -1;
  int y = -1;
  for (int i = 0; i <= n; ++i) {
    int ones = i;
    int twos = n - i;
    int left_bound = 0, right_bound = min(ones, m);
    bool good = true;
    if (2 * twos < m) {
      left_bound = m - 2 * twos;
    }
    if (left_bound <= right_bound) {
      int u = left_bound;
      int v = (m + 1 - u) / 2;
      if (u + 2 * v > m) {
        ++u;
        --v;
      }
      if (u <= right_bound) {
        long long score = calc(u, v);
        if (score < best) {
          best = score;
          split = i;
          x = u;
          y = v;
        }
        if (u + 2 <= right_bound) {
          int l = 1, r = (right_bound - u) / 2;
          r = min(r, v);
          while (r - l > 1) {
            int k = (l + r) / 2;
            if (check(u, v, k)) {
              l = k;
            } else {
              r = k;
            }
          }
          int bound = r;
          if (check(u, v, r)) {
            bound = r;
          } else {
            bound = l;
          }
          long long current = calc(u + 2 * bound, v - bound);
          if (current < best) {
            best = current;
            split = i;
            x = u + 2 * bound;
            y = v - bound;
          }
        }
      }
    }
    if (i != n) {
      updateC(cntA, posA[order[i]], +1);
      updateF(fA, posA[order[i]], a[order[i]]);
      updateC(cntB, posB[order[i]], -1);
      updateF(fB, posB[order[i]], -b[order[i]]);
    }
  }
  cout << best << endl;
  vector<pair<int, int> > sA, sB;
  for (int i = 0; i < n; ++i) {
    if (i < split) {
      sA.push_back(make_pair(a[order[i]], order[i]));
    } else {
      sB.push_back(make_pair(b[order[i]], order[i]));
    }
  }
  sort(sA.begin(), sA.end());
  sort(sB.begin(), sB.end());
  for (int i = 0; i < x; ++i) {
    res[sA[i].second] = 1;
  }
  for (int i = 0; i < y; ++i) {
    res[sB[i].second] = 2;
  }
  for (int i = 0; i < n; ++i) {
    printf("%d", res[i]);
  }
  printf("\n");
  return 0;
}