#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int weight[N], cost[N];
pair<int, int> edges[N];
int arr[N], isUsed[N];
int parent[N], height[N];
vector<pair<int, int>> adj[N];
int dp[N][20];
int dp2[N][20];
int depth[N];
int logtable[N];
bool cmp(const int a, const int b) { return weight[a] < weight[b]; }
int findP(int x) {
  if (parent[x] == x)
    return x;
  else
    return parent[x] = findP(parent[x]);
}
void unionP(int a, int b) {
  if (height[a] > height[b]) swap(a, b);
  parent[a] = b;
  height[b] = max(height[b], 1 + height[a]);
}
void dfs(int v, int p, int d, int e) {
  depth[v] = d;
  dp[v][0] = p;
  dp2[v][0] = e;
  for (int i = 1; i <= logtable[depth[v]]; i++) {
    dp[v][i] = dp[dp[v][i - 1]][i - 1];
    dp2[v][i] = max(dp2[v][i - 1], dp2[dp[v][i - 1]][i - 1]);
  }
  for (auto c : adj[v]) {
    if (c.first != p) dfs(c.first, v, d + 1, c.second);
  }
}
int lca(int a, int b) {
  if (depth[a] > depth[b]) swap(a, b);
  int s = 0;
  for (int i = logtable[depth[b]]; i >= 0; i--) {
    if (depth[b] - (1 << i) >= depth[a]) {
      s = max(s, dp2[b][i]);
      b = dp[b][i];
    }
  }
  if (a != b) {
    for (int i = logtable[depth[b]]; i >= 0; i--) {
      if (dp[b][i] != dp[a][i]) {
        s = max(s, max(dp2[a][i], dp2[b][i]));
        a = dp[a][i];
        b = dp[b][i];
      }
    }
    s = max(s, max(dp2[a][0], dp2[b][0]));
  }
  return s;
}
int main() {
  int n, m, u, v, e;
  scanf("%d %d", &n, &m);
  long long e2, e3;
  for (int i = 1; i <= n; i++) parent[i] = i;
  for (int i = 1; i <= m; i++) scanf("%d", weight + i);
  for (int i = 1; i <= m; i++) scanf("%d", cost + i);
  for (int i = 1; i <= m; i++) {
    scanf("%d %d", &u, &v);
    edges[i].first = u, edges[i].second = v;
    arr[i] = i;
  }
  int S;
  scanf("%d", &S);
  sort(arr + 1, arr + 1 + m, cmp);
  long long total = 0;
  int count = 0;
  for (int i = 1; i <= m; i++) {
    e = arr[i];
    u = findP(edges[e].first);
    v = findP(edges[e].second);
    if (u == v) continue;
    isUsed[e] = 1;
    unionP(u, v);
    total += weight[e];
    u = edges[e].first;
    v = edges[e].second;
    count++;
    adj[u].push_back({v, weight[e]});
    adj[v].push_back({u, weight[e]});
  }
  long long best = total;
  logtable[0] = -1;
  for (int i = 1; i <= n; i++) {
    logtable[i] = logtable[i - 1];
    if ((i & -i) == i) logtable[i]++;
  }
  dfs(1, 0, 0, 0);
  int ind = -1;
  long long xx = 0;
  for (int i = 1; i <= m; i++) {
    e = lca(edges[i].first, edges[i].second);
    e2 = weight[i] - (S / cost[i]);
    e3 = total - e + e2;
    if (e3 <= best) {
      best = e3;
      ind = i;
      xx = e2;
    }
  }
  cout << best << endl;
  cout << ind << " " << xx << endl;
  for (int i = 1; i <= n; i++) {
    parent[i] = i;
    height[i] = 0;
  }
  unionP(edges[ind].first, edges[ind].second);
  for (int i = 1; i <= m; i++) {
    e = arr[i];
    u = findP(edges[e].first);
    v = findP(edges[e].second);
    if (u == v) continue;
    unionP(u, v);
    printf("%d %d\n", e, weight[e]);
  }
  return 0;
}
