#include <bits/stdc++.h>
using namespace std;
long long n, m, c[((long long)101 * 1000)], w[((long long)101 * 1000)], res;
pair<long long, long long> ans[((long long)101 * 1000)];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
    ans[i] = {c[i] / 100, c[i] % 100};
    c[i] %= 100;
  }
  set<pair<long long, long long> > s;
  for (int i = 0; i < n; i++) {
    cin >> w[i];
    if (c[i]) s.insert({(100 - c[i]) * w[i], i});
    if (m - c[i] < 0) {
      pair<long long, long long> x = *s.begin();
      s.erase(s.begin());
      m += 100;
      res += x.first;
      ans[x.second].first++;
      ans[x.second].second = 0;
    }
    m -= c[i];
  }
  cout << res << "\n";
  for (int i = 0; i < n; i++)
    cout << ans[i].first << " " << ans[i].second << "\n";
  return 0;
}
