#include <bits/stdc++.h>
using namespace std;
int mult(int x, int y) {
  long long int ans, x1 = (long long int)x, y1 = (long long int)y;
  ans = (x1 * y1) % 1000000007;
  return (int)ans;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
long long int pow1(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int mina(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] < x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
int maxa(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] > x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
vector<vector<int> > v, indexa, costs;
int base[200005], ptr;
int chainno, chainind[200005], chainhead[200005], posinbase[200005];
int depth[200005], p[22][200005], otherend[200005], child[200005];
pair<int, int> st[200005 * 6];
int revmap[200005];
vector<pair<int, int> > e;
int w[200005], c[200005];
int endpt1[200005], endpt2[200005];
void build(int low, int high, int pos) {
  if (low == high) {
    st[pos] = make_pair(base[low], revmap[low]);
    return;
  }
  int mid = (low + high) >> 1;
  build(low, mid, 2 * pos);
  build(mid + 1, high, 2 * pos + 1);
  int lft = st[2 * pos].first, rht = st[2 * pos + 1].first;
  if (lft >= rht)
    st[pos] = st[2 * pos];
  else
    st[pos] = st[2 * pos + 1];
}
pair<int, int> rmq(int low, int high, int l, int r, int pos) {
  if (high < l || low > r) return make_pair(-INT_MAX, -1);
  if (l <= low && r >= high) return st[pos];
  int mid = (low + high) >> 1;
  pair<int, int> lft = rmq(low, mid, l, r, 2 * pos),
                 rht = rmq(mid + 1, high, l, r, 2 * pos + 1);
  if (lft.first >= rht.first)
    return lft;
  else
    return rht;
}
pair<int, int> query_up(int u1, int v1) {
  int uchain, vchain = chainind[v1], ind;
  pair<int, int> ans = make_pair(-INT_MAX, -1);
  while (true) {
    uchain = chainind[u1];
    if (uchain == vchain) {
      if (u1 == v1) break;
      pair<int, int> quer =
          rmq(1, ptr - 1, posinbase[v1] + 1, posinbase[u1], 1);
      ans = max(ans, quer);
      break;
    }
    ans = max(ans,
              rmq(1, ptr - 1, posinbase[chainhead[uchain]], posinbase[u1], 1));
    u1 = chainhead[uchain];
    u1 = p[0][u1];
  }
  return ans;
}
int lca(int u1, int v1) {
  if (depth[u1] < depth[v1]) swap(u1, v1);
  int diff = depth[u1] - depth[v1], i, j;
  for (i = 0; i < 22; i++)
    if ((diff >> i) & 1) u1 = p[i][u1];
  if (u1 == v1) return u1;
  for (i = 22 - 1; i >= 0; i--)
    if (p[i][u1] != p[i][v1]) {
      u1 = p[i][u1];
      v1 = p[i][v1];
    }
  return p[0][u1];
}
pair<int, int> query(int u1, int v1) {
  int comm = lca(u1, v1);
  return max(query_up(u1, comm), query_up(v1, comm));
}
map<pair<int, int>, int> m1;
void hld(int curnode, int cost, int n, int indx) {
  if (chainhead[chainno] == -1) chainhead[chainno] = curnode;
  chainind[curnode] = chainno;
  posinbase[curnode] = ptr;
  revmap[ptr] = indx;
  base[ptr++] = cost;
  int mxchild = -1, ncost = 0, i, j, cnt = 0, pos1;
  for (vector<int>::iterator itr = v[curnode].begin(); itr != v[curnode].end();
       itr++) {
    int v1 = *itr;
    if (v1 != p[0][curnode]) {
      if (mxchild == -1 || child[mxchild] < child[v1])
        mxchild = v1, ncost = costs[curnode][cnt];
    }
    cnt++;
  }
  cnt = 0;
  if (mxchild != -1) hld(mxchild, ncost, n, m1[make_pair(curnode, mxchild)]);
  for (vector<int>::iterator itr = v[curnode].begin(); itr != v[curnode].end();
       itr++) {
    int v1 = *itr;
    if (v1 != p[0][curnode] && v1 != mxchild) {
      chainno++;
      hld(v1, costs[curnode][cnt], n, m1[make_pair(curnode, v1)]);
    }
    cnt++;
  }
}
void dfs(int u, int par) {
  if (u == 1)
    depth[u] = 0;
  else
    depth[u] = depth[par] + 1;
  p[0][u] = par;
  child[u] = 1;
  int cnt = 0;
  for (vector<int>::iterator itr = v[u].begin(); itr != v[u].end(); itr++) {
    int v1 = *itr;
    if (v1 != par) {
      otherend[indexa[u][cnt]] = v1;
      dfs(v1, u);
      child[u] += child[v1];
    }
    cnt++;
  }
}
int arr1[200005], arr2[200005];
bool mark[200005];
int finda(int i) {
  if (arr1[i] == i)
    return i;
  else
    return arr1[i] = finda(arr1[i]);
}
void makeunion(int a, int b) {
  int a1 = finda(a);
  int a2 = finda(b);
  if (arr2[a1] < arr2[a2])
    arr1[a1] = a2;
  else if (arr2[a2] < arr2[a1])
    arr1[a2] = a1;
  else {
    arr2[a1]++;
    arr1[a2] = a1;
  }
}
int main() {
  int x, y, n, m, i, j, k;
  long long int tot;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 1; i < m + 1; i++) scanf("%d", &w[i]);
  for (i = 1; i < m + 1; i++) scanf("%d", &c[i]);
  for (i = 1; i < m + 1; i++) {
    scanf("%d", &x);
    scanf("%d", &y);
    endpt1[i] = x;
    endpt2[i] = y;
    e.push_back(make_pair(w[i], i));
  }
  scanf("%lld", &tot);
  sort(e.begin(), e.end());
  for (i = 1; i < n + 1; i++) {
    arr1[i] = i;
    arr2[i] = 1;
  }
  long long int cost = 0;
  v.resize(n + 2);
  costs.resize(n + 2);
  indexa.resize(n + 2);
  for (i = 0; i < n + 2; i++) {
    chainhead[i] = -1;
    for (j = 0; j < 22; j++) p[j][i] = -1;
  }
  int cn = 0;
  vector<int> final;
  for (i = 0; i < m; i++) {
    pair<int, int> front = e[i];
    int u1 = endpt1[front.second], v1 = endpt2[front.second];
    int a = finda(u1);
    int b = finda(v1);
    if (a != b) {
      final.push_back(front.second);
      v[u1].push_back(v1);
      v[v1].push_back(u1);
      m1[make_pair(u1, v1)] = front.second;
      m1[make_pair(v1, u1)] = front.second;
      costs[u1].push_back(front.first);
      costs[v1].push_back(front.first);
      indexa[u1].push_back(cn);
      indexa[v1].push_back(cn++);
      mark[front.second] = true;
      cost += front.first;
      makeunion(endpt1[front.second], endpt2[front.second]);
    }
  }
  dfs(1, -1);
  ptr = 1;
  chainno = 0;
  hld(1, -INT_MAX, n, 0);
  build(1, ptr - 1, 1);
  for (i = 1; i < 22; i++)
    for (j = 0; j < n + 1; j++)
      if (p[i - 1][j] != -1) p[i][j] = p[i - 1][p[i - 1][j]];
  long long int ans = LLONG_MAX;
  pair<int, int> indx = make_pair(-INT_MAX, -INT_MAX);
  for (i = 1; i < m + 1; i++) {
    if (mark[i]) {
      if (cost - (tot / (long long int)c[i]) < ans)
        indx = make_pair(-INT_MAX, i);
      ans = min(ans, cost - (tot / (long long int)c[i]));
      continue;
    }
    int u1 = endpt1[i], v1 = endpt2[i];
    pair<int, int> pra = query(u1, v1);
    long long int cost1 = (long long int)pra.first;
    int ind = pra.second;
    if (w[i] - (int)(tot / c[i]) < (int)cost1) {
      if (cost - cost1 + (long long int)w[i] - (tot / c[i]) < ans)
        indx = make_pair(i, ind);
      ans = min(ans, cost - cost1 + (long long int)w[i] - (tot / c[i]));
    }
  }
  printf("%lld\n", ans);
  if (indx.first == -INT_MAX) {
    for (i = 0; i < final.size(); i++) {
      if (final[i] != indx.second)
        printf("%d %d\n", final[i], w[final[i]]);
      else
        printf("%d %d\n", final[i], w[final[i]] - (int)(tot / c[final[i]]));
    }
  } else {
    for (i = 0; i < final.size(); i++) {
      if (final[i] != indx.second)
        printf("%d %d\n", final[i], w[final[i]]);
      else
        printf("%d %d\n", indx.first,
               w[indx.first] - (int)(tot / c[indx.first]));
    }
  }
  return 0;
}
