#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long w[200005];
long long c[200005];
long long S;
vector<long long> idxw, idxc;
struct DS {
  long long n;
  long long par[400005];
  long long size[400005];
  void build(long long n) {
    this->n = n;
    for (long long i = 1; i <= n; ++i) {
      par[i] = -1;
      size[i] = 1;
    }
  }
  long long getParent(long long x) {
    if (par[x] == -1) {
      return x;
    }
    par[x] = getParent(par[x]);
    return par[x];
  }
  bool isSameSet(long long x, long long y) {
    return (getParent(x) == getParent(y));
  }
  void setUnion(long long x, long long y) {
    if (isSameSet(x, y)) {
      return;
    }
    long long px = getParent(x);
    long long py = getParent(y);
    if (size[px] < size[py]) {
      par[px] = py;
      size[py] += size[px];
    } else {
      par[py] = px;
      size[px] += size[py];
    }
  }
};
DS ds;
struct Edge {
  long long u;
  long long v;
  long long w;
  long long c;
  Edge(long long u, long long v, long long w, long long c) {
    this->u = u;
    this->v = v;
    this->w = w;
    this->c = c;
  }
};
vector<Edge> edges;
bool cmpw(long long i, long long j) { return (edges[i].w < edges[j].w); }
bool cmpc(long long i, long long j) { return (edges[i].c < edges[j].c); }
vector<long long> nei[200005];
long long logn = 20;
long long mstw = 0;
set<long long> mstedges;
long long p[200005][20];
long long maxidx[200005][20];
long long lev[200005];
long long ans[200005];
void buildMST() {
  long long idx = 0;
  while (mstedges.size() < n - 1) {
    Edge e = edges[idxw[idx++]];
    if (!ds.isSameSet(e.u, e.v)) {
      ds.setUnion(e.u, e.v);
      nei[e.u].push_back(idxw[idx - 1]);
      nei[e.v].push_back(idxw[idx - 1]);
      mstedges.insert(idxw[idx - 1]);
      mstw += e.w;
    }
  }
}
void dfs(long long u) {
  for (long long i = 0; i < nei[u].size(); ++i) {
    long long v;
    if (edges[nei[u][i]].u == u) {
      v = edges[nei[u][i]].v;
    } else {
      v = edges[nei[u][i]].u;
    }
    if (v != p[u][0]) {
      p[v][0] = u;
      lev[v] = lev[u] + 1;
      maxidx[v][0] = nei[u][i];
      dfs(v);
    }
  }
}
void buildp() {
  for (long long i = 1; i < logn; ++i) {
    for (long long u = 1; u <= n; ++u) {
      maxidx[u][i] = maxidx[u][i - 1];
      if (p[u][i - 1] != -1) {
        p[u][i] = p[p[u][i - 1]][i - 1];
        if (edges[maxidx[p[u][i - 1]][i - 1]].w > edges[maxidx[u][i]].w) {
          maxidx[u][i] = maxidx[p[u][i - 1]][i - 1];
        }
      }
    }
  }
}
long long minbw(long long u, long long v) {
  long long V = v;
  long long U = u;
  if (lev[u] < lev[v]) {
    return minbw(v, u);
  }
  long long ret = -1;
  long long diff = lev[u] - lev[v];
  for (long long i = logn - 1; i >= 0; --i) {
    if ((1 << i) & diff) {
      if (ret == -1 || edges[ret].w < edges[maxidx[u][i]].w) {
        ret = maxidx[u][i];
      }
      u = p[u][i];
    }
  }
  if (u == v) {
    return ret;
  }
  for (long long i = logn - 1; i >= 0; --i) {
    if (p[u][i] != p[v][i]) {
      if (ret == -1 || edges[maxidx[u][i]].w > edges[ret].w) {
        ret = maxidx[u][i];
      }
      if (ret == -1 || edges[maxidx[v][i]].w > edges[ret].w) {
        ret = maxidx[v][i];
      }
      u = p[u][i];
      v = p[v][i];
    }
  }
  if (ret == -1 || edges[maxidx[u][0]].w > edges[ret].w) {
    ret = maxidx[u][0];
  }
  if (ret == -1 || edges[maxidx[v][0]].w > edges[ret].w) {
    ret = maxidx[v][0];
  }
  return ret;
}
long long getnewmstw(long long idx) {
  Edge e = edges[idx];
  long long minwidx = minbw(e.u, e.v);
  return mstw - edges[minwidx].w + e.w;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  ds.build(n);
  logn = log2(n) + 1;
  for (long long i = 0; i < m; ++i) {
    cin >> w[i];
  }
  for (long long i = 0; i < m; ++i) {
    cin >> c[i];
  }
  for (long long i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    edges.push_back(Edge(a, b, w[i], c[i]));
    idxw.push_back(i);
    idxc.push_back(i);
  }
  sort(idxw.begin(), idxw.end(), cmpw);
  sort(idxc.begin(), idxc.end(), cmpc);
  cin >> S;
  for (long long i = 0; i < 200005; ++i) {
    for (long long j = 0; j < 20; ++j) {
      p[i][j] = -1;
      maxidx[i][j] = -1;
    }
  }
  buildMST();
  lev[1] = 0;
  dfs(1);
  buildp();
  for (long long i = 0; i < idxc.size(); ++i) {
    long long idx = idxc[i];
    if (mstedges.find(idx) != mstedges.end()) {
      ans[idx] = mstw - S / c[idx];
    } else {
      ans[idx] = getnewmstw(idx) - S / c[idx];
    }
  }
  long long mindx = 0;
  for (long long i = 0; i < m; ++i) {
    if (ans[i] < ans[mindx]) {
      mindx = i;
    }
  }
  cout << ans[mindx] << endl;
  if (mstedges.find(mindx) != mstedges.end()) {
    for (set<long long>::iterator it = mstedges.begin(); it != mstedges.end();
         ++it) {
      if (*it == mindx) {
        cout << *it + 1 << " " << edges[*it].w - S / c[*it] << endl;
      } else {
        cout << *it + 1 << " " << edges[*it].w << endl;
      }
    }
  } else {
    Edge e = edges[mindx];
    long long remidx = minbw(e.u, e.v);
    for (set<long long>::iterator it = mstedges.begin(); it != mstedges.end();
         ++it) {
      if (*it != remidx) {
        cout << *it + 1 << " " << edges[*it].w << endl;
      }
    }
    cout << mindx + 1 << " " << edges[mindx].w - S / c[mindx] << endl;
  }
}
