#include <bits/stdc++.h>
const long double eps = 1e-8;
const long double pi = acos(-1);
using namespace std;
char temp[300005];
int ar[] = {0, 0, -1, 1, 1, 1, -1, -1};
int ac[] = {-1, 1, 0, 0, 1, -1, -1, 1};
int a[300005], w[300005];
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m;
  vector<long long> ve, res(n);
  priority_queue<pair<long long, long long>, vector<pair<long long, long long>>,
                 greater<pair<long long, long long>>>
      pq;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    ve.push_back(a[i] % 100);
  }
  for (int i = 0; i < n; i++) cin >> w[i];
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    long long x = ve[i];
    if (x % 100 == 0) continue;
    pq.push(make_pair((100 - x) * w[i], i));
    if (x <= m) {
      res[i] = x;
      m -= x;
    } else {
      long long low = pq.top().first;
      long long pos = pq.top().second;
      res[i] = ve[i];
      res[pos] = 0;
      a[pos] += 100;
      m -= ve[i];
      m += ve[pos];
      m += 100 - ve[pos];
      sum += low;
      pq.pop();
    }
  }
  cout << sum << "\n";
  for (int i = 0; i < n; i++) cout << a[i] / 100 << " " << res[i] << "\n";
  return 0;
}
