#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.);
const int MOD = 1000 * 1000 * 1000 + 7;
int main() {
  long long n, m;
  cin >> n >> m;
  vector<long long> c(n + 1), ansB(n + 1, 0), ansM(n + 1, 0), w(n + 1);
  vector<vector<pair<long long, long long>>> dp(
      n + 1, vector<pair<long long, long long>>(2, {0, 0}));
  for (int i = 1; i <= n; ++i) {
    cin >> c[i];
    ansB[i] = c[i] / 100;
    c[i] %= 100;
  }
  for (int i = 1; i <= n; ++i) cin >> w[i];
  long long ans = 0;
  set<pair<int, int>> processed;
  for (int i = 1; i <= n; ++i) {
    if (m >= c[i]) {
      ansM[i] = c[i];
      if (c[i]) processed.insert({w[i] * (100 - c[i]), i});
      m -= c[i];
    } else {
      m += 100;
      ansM[i] = c[i];
      if (c[i]) processed.insert({w[i] * (100 - c[i]), i});
      int id = (*processed.begin()).second;
      ans += (*processed.begin()).first;
      ansB[id] += 1;
      ansM[id] = 0;
      processed.erase(processed.begin());
      m -= c[i];
    }
  }
  cout << ans << endl;
  for (int i = 1; i <= n; ++i) cout << ansB[i] << " " << ansM[i] << endl;
  return 0;
}
