#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
pair<long long, int> tree[400010];
int N, ind;
long long M;
long long val;
void upd(int n = 0, int l = 0, int r = N - 1) {
  if (l == r) {
    tree[n] = {val, l};
    return;
  }
  int md = (l + r) >> 1;
  if (ind <= md)
    upd(2 * n + 1, l, md);
  else
    upd(2 * n + 2, md + 1, r);
  tree[n] = min(tree[2 * n + 1], tree[2 * n + 2]);
}
pair<long long, int> get(int a, int b, int n = 0, int l = 0, int r = N - 1) {
  if (l == a && b == r) {
    return tree[n];
  }
  int md = (l + r) >> 1;
  pair<long long, int> res = {LLONG_MAX, INT_MAX};
  if (a <= md) res = get(a, min(b, md), 2 * n + 1, l, md);
  if (b > md) res = min(res, get(max(a, md + 1), b, 2 * n + 2, md + 1, r));
  return res;
}
bool out[100010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> N >> M;
  vector<int> c(N), w(N);
  vector<pair<int, int> > a(N);
  for (int i = 0; i < N; i++) cin >> c[i];
  for (int i = 0; i < N; i++) cin >> w[i];
  for (int i = 0; i < N; i++) {
    ind = i;
    val = (100 - (c[i] % 100)) * w[i];
    if (c[i] % 100 == 0) {
      val = LLONG_MAX;
    }
    upd();
  }
  long long res = 0;
  long long cur = 0;
  for (int i = 0; i < N; i++) {
    cur += c[i] % 100;
    if (cur > M) {
      pair<long long, int> u = get(0, i);
      M += 100;
      res += u.first;
      out[u.second] = true;
      ind = u.second;
      val = LLONG_MAX;
      upd();
    }
  }
  cout << res << '\n';
  for (int i = 0; i < N; i++) {
    if (out[i]) {
      assert(c[i] % 100 != 0);
      cout << c[i] / 100 + 1 << " 0\n";
    } else {
      cout << c[i] / 100 << ' ' << c[i] % 100 << '\n';
    }
  }
  return 0;
}
