#include <bits/stdc++.h>
using namespace std;
long long int n, m, c[100005], w[100005], a[100005], pr[100005], mark[100005];
bool cmp(long long int i, long long int j) {
  long long int c1 = ((100 - (c[i] % 100)) % 100) * w[i];
  long long int c2 = ((100 - (c[j] % 100)) % 100) * w[j];
  if (c1 != c2) return c1 > c2;
  return i > j;
}
long long int seg[500005], pen[500005];
void build(long long int idx, long long int lo, long long int hi) {
  if (lo == hi) {
    seg[idx] = pr[lo];
    return;
  }
  long long int mid = (lo + hi) / 2;
  build(2 * idx, lo, mid);
  build(2 * idx + 1, mid + 1, hi);
  seg[idx] = min(seg[2 * idx], seg[2 * idx + 1]);
}
void lazyprop(long long int idx) {
  seg[idx] += pen[idx];
  pen[2 * idx] += pen[idx];
  pen[2 * idx + 1] += pen[idx];
  pen[idx] = 0;
}
void update(long long int idx, long long int lo, long long int hi,
            long long int st, long long int en, long long int val) {
  if (lo == st && hi == en) {
    if (lo == hi)
      seg[idx] += val;
    else
      pen[idx] += val;
    return;
  }
  if (pen[idx]) lazyprop(idx);
  long long int mid = (lo + hi) / 2;
  if (en <= mid)
    update(2 * idx, lo, mid, st, en, val);
  else if (st > mid)
    update(2 * idx + 1, mid + 1, hi, st, en, val);
  else {
    update(2 * idx, lo, mid, st, mid, val);
    update(2 * idx + 1, mid + 1, hi, mid + 1, en, val);
  }
  seg[idx] =
      min(seg[2 * idx] + pen[2 * idx], seg[2 * idx + 1] + pen[2 * idx + 1]);
}
long long int query(long long int idx, long long int lo, long long int hi,
                    long long int st, long long int en) {
  if (lo == st && hi == en) return seg[idx] + pen[idx];
  if (pen[idx]) lazyprop(idx);
  long long int mid = (lo + hi) / 2;
  if (en <= mid)
    return query(2 * idx, lo, mid, st, en);
  else if (st > mid)
    return query(2 * idx + 1, mid + 1, hi, st, en);
  else
    return min(query(2 * idx, lo, mid, st, mid),
               query(2 * idx + 1, mid + 1, hi, mid + 1, en));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (long long int i = 1; i <= n; ++i) cin >> c[i];
  for (long long int i = 1; i <= n; ++i) cin >> w[i];
  for (long long int i = 1; i <= n; ++i) a[i] = i;
  sort(a + 1, a + n + 1, cmp);
  pr[0] = m;
  long long int ans = 0;
  for (long long int i = 1; i <= n; ++i) {
    pr[i] = pr[i - 1];
    pr[i] += ((100 - (c[i] % 100)) % 100);
    ans += ((100 - (c[i] % 100)) % 100) * w[i];
  }
  build(1, 1, n);
  for (long long int i = 1; i <= n; ++i) {
    if (c[a[i]] % 100 == 0) continue;
    long long int ps = a[i];
    long long int mi = query(1, 1, n, ps, n);
    if (mi < 100) continue;
    update(1, 1, n, ps, n, -100);
    ans -= ((100 - (c[ps] % 100)) % 100) * w[ps];
    mark[ps] = 1;
  }
  cout << ans << '\n';
  for (long long int i = 1; i <= n; ++i) {
    if (c[i] % 100 == 0)
      cout << c[i] / 100 << " " << 0 << '\n';
    else if (!mark[i])
      cout << (c[i] + 99) / 100 << " " << 0 << '\n';
    else
      cout << c[i] / 100 << " " << c[i] % 100 << '\n';
  }
}
