#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100010;
int c[MAXN], w[MAXN];
bool changefree[MAXN];
int main() {
  ios::sync_with_stdio(false);
  int n;
  long long m;
  cin >> n >> m;
  for (int i = 0; i < (n); ++i) {
    cin >> c[i];
  }
  for (int i = 0; i < (n); ++i) cin >> w[i];
  long long ans = 0;
  set<pair<int, int> > st;
  for (int i = 0; i < (n); ++i) {
    int auxc = c[i] % 100;
    if (!auxc) {
      changefree[i] = true;
      continue;
    }
    if (m >= auxc) {
      m -= auxc;
      changefree[i] = true;
      st.insert({(100 - auxc) * w[i], i});
    } else {
      if (!st.empty()) {
        int myfee = (100 - auxc) * w[i];
        if (myfee > st.begin()->first) {
          m += 100;
          auto p = *st.begin();
          st.erase(st.begin());
          changefree[p.second] = false;
          changefree[i] = true;
          ans += p.first;
          m -= auxc;
          st.insert({(100 - auxc) * w[i], i});
          continue;
        }
      }
      changefree[i] = false;
      ans += (100 - auxc) * w[i];
      m += 100 - auxc;
    }
  }
  cout << ans << endl;
  for (int i = 0; i < (n); ++i) {
    if (changefree[i])
      cout << c[i] / 100 << " " << c[i] % 100 << endl;
    else
      cout << c[i] / 100 + 1 << " " << 0 << endl;
  }
  return 0;
}
