#include <bits/stdc++.h>
const int MX = 1e6 + 23;
const long long MOD = 998244353;
int read() {
  char k = getchar();
  int x = 0;
  while (k < '0' || k > '9') k = getchar();
  while (k >= '0' && k <= '9') x = x * 10 + k - '0', k = getchar();
  return x;
}
int n, m, c[MX], w[MX];
int a[MX], b[MX];
struct Choice {
  int w, id;
  bool operator<(const Choice &B) const { return w > B.w; }
};
int cho[MX];
void solve() {
  n = read(), m = read();
  for (int i = 1; i <= n; ++i) {
    c[i] = read();
    a[i] = c[i] / 100;
    b[i] = c[i] % 100;
    if (!b[i]) cho[i] = 1;
  }
  long long ans = 0;
  std::priority_queue<Choice> q;
  for (int i = 1; i <= n; ++i) {
    w[i] = read();
    if (m >= b[i]) {
      if (b[i]) {
        q.push((Choice){(100 - b[i]) * w[i], i});
      }
    } else {
      if (!q.empty() && q.top().w <= (100 - b[i]) * w[i]) {
        ans += q.top().w;
        q.pop();
        q.push((Choice){(100 - b[i]) * w[i], i});
      } else {
        ans += (100 - b[i]) * w[i];
      }
      m += 100;
    }
    m -= b[i];
  }
  printf("%lld\n", ans);
  while (!q.empty()) {
    cho[q.top().id] = 1;
    q.pop();
  }
  for (int i = 1; i <= n; ++i) {
    if (cho[i]) {
      printf("%d %d\n", a[i], b[i]);
    } else
      printf("%d %d\n", a[i] + 1, 0);
  }
}
int main() {
  int T = 1;
  for (int i = 1; i <= T; ++i) {
    solve();
  }
  return 0;
}
