#include <bits/stdc++.h>
using namespace std;
void trace_() { cerr << "\n"; }
template <typename T1, typename... T2>
void trace_(T1 t1, T2... t2) {
  cerr << ' ' << t1;
  trace_(t2...);
}
const long long mxN = 1e5 + 5;
long long n, m, c[mxN], w[mxN], note[mxN], ans[mxN];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 0; i < n; i++)
    cin >> c[i], note[i] = c[i] / 100, c[i] %= 100;
  for (long long i = 0; i < n; i++) cin >> w[i];
  long long dis = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  for (long long i = 0; i < n; i++) {
    if (c[i] == 0) {
      ans[i] = 1;
      continue;
    }
    if (m >= c[i]) {
      m -= c[i];
      pq.emplace((100 - c[i]) * w[i], i);
      ans[i] = 1;
    } else {
      long long cost = (100 - c[i]) * w[i];
      if (!pq.empty() and
          (pq.top().first < cost or
           (pq.top().first == cost and c[i] < c[pq.top().second]))) {
        m += 100 - c[i];
        dis += pq.top().first;
        ans[pq.top().second] = 0;
        pq.pop();
        pq.emplace(cost, i);
        ans[i] = 1;
      } else {
        m += 100 - c[i];
        dis += cost;
      }
    }
  }
  cout << dis << '\n';
  for (long long i = 0; i < n; i++) {
    if (ans[i])
      cout << note[i] << ' ' << c[i] << '\n';
    else
      cout << note[i] + 1 << ' ' << "0\n";
  }
}

### Prompt

Create a solution in cpp for the following problem:

Student Arseny likes to plan his life for n days ahead. He visits a canteen every day and he has already decided what he will order in each of the following n days. Prices in the canteen do not change and that means Arseny will spend ci rubles during the i-th day.

There are 1-ruble coins and 100-ruble notes in circulation. At this moment, Arseny has m coins and a sufficiently large amount of notes (you can assume that he has an infinite amount of them). Arseny loves modern technologies, so he uses his credit card everywhere except the canteen, but he has to pay in cash in the canteen because it does not accept cards.

Cashier always asks the student to pay change-free. However, it's not always possible, but Arseny tries to minimize the dissatisfaction of the cashier. Cashier's dissatisfaction for each of the days is determined by the total amount of notes and coins in the change. To be precise, if the cashier gives Arseny x notes and coins on the i-th day, his dissatisfaction for this day equals x·wi. Cashier always gives change using as little coins and notes as possible, he always has enough of them to be able to do this.

<image> "Caution! Angry cashier"

Arseny wants to pay in such a way that the total dissatisfaction of the cashier for n days would be as small as possible. Help him to find out how he needs to pay in each of the n days!

Note that Arseny always has enough money to pay, because he has an infinite amount of notes. Arseny can use notes and coins he received in change during any of the following days.

Input

The first line contains two integers n and m (1 ≤ n ≤ 105, 0 ≤ m ≤ 109) — the amount of days Arseny planned his actions for and the amount of coins he currently has. 

The second line contains a sequence of integers c1, c2, ..., cn (1 ≤ ci ≤ 105) — the amounts of money in rubles which Arseny is going to spend for each of the following days. 

The third line contains a sequence of integers w1, w2, ..., wn (1 ≤ wi ≤ 105) — the cashier's dissatisfaction coefficients for each of the following days.

Output

In the first line print one integer — minimum possible total dissatisfaction of the cashier.

Then print n lines, the i-th of then should contain two numbers — the amount of notes and the amount of coins which Arseny should use to pay in the canteen on the i-th day.

Of course, the total amount of money Arseny gives to the casher in any of the days should be no less than the amount of money he has planned to spend. It also shouldn't exceed 106 rubles: Arseny never carries large sums of money with him.

If there are multiple answers, print any of them.

Examples

Input

5 42
117 71 150 243 200
1 1 1 1 1


Output

79
1 17
1 0
2 0
2 43
2 0


Input

3 0
100 50 50
1 3 2


Output

150
1 0
1 0
0 50


Input

5 42
117 71 150 243 200
5 4 3 2 1


Output

230
1 17
1 0
1 50
3 0
2 0

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void trace_() { cerr << "\n"; }
template <typename T1, typename... T2>
void trace_(T1 t1, T2... t2) {
  cerr << ' ' << t1;
  trace_(t2...);
}
const long long mxN = 1e5 + 5;
long long n, m, c[mxN], w[mxN], note[mxN], ans[mxN];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ;
  cin >> n >> m;
  for (long long i = 0; i < n; i++)
    cin >> c[i], note[i] = c[i] / 100, c[i] %= 100;
  for (long long i = 0; i < n; i++) cin >> w[i];
  long long dis = 0;
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  for (long long i = 0; i < n; i++) {
    if (c[i] == 0) {
      ans[i] = 1;
      continue;
    }
    if (m >= c[i]) {
      m -= c[i];
      pq.emplace((100 - c[i]) * w[i], i);
      ans[i] = 1;
    } else {
      long long cost = (100 - c[i]) * w[i];
      if (!pq.empty() and
          (pq.top().first < cost or
           (pq.top().first == cost and c[i] < c[pq.top().second]))) {
        m += 100 - c[i];
        dis += pq.top().first;
        ans[pq.top().second] = 0;
        pq.pop();
        pq.emplace(cost, i);
        ans[i] = 1;
      } else {
        m += 100 - c[i];
        dis += cost;
      }
    }
  }
  cout << dis << '\n';
  for (long long i = 0; i < n; i++) {
    if (ans[i])
      cout << note[i] << ' ' << c[i] << '\n';
    else
      cout << note[i] + 1 << ' ' << "0\n";
  }
}

```