#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(const vector<bool>& v) {
  bool first = true;
  string res = "{";
  for (auto&& i : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(i);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res;
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int mxn = 2e5 + 19, K = 25;
int n, m;
long long s;
long long c[mxn];
long long w[mxn];
int vis[mxn];
int lca[mxn][K];
int minLca[mxn][K];
int dep[mxn];
int us[mxn];
int topEdge[mxn];
pair<int, int> edges[mxn];
vector<pair<int, int> > graph[mxn];
long long getMin(int a, int b) {
  int ans = 1e9;
  if (dep[a] < dep[b]) {
    swap(a, b);
  }
  for (int l = K - 1; l >= 0; l--) {
    if (dep[a] - (1 << l) >= dep[b]) {
      ans = min(ans, minLca[a][l]);
      a = lca[a][l];
    }
  }
  if (a == b) {
    return ans;
  }
  for (int l = K - 1; l >= 0; l--) {
    if (lca[a][l] != lca[b][l]) {
      ans = min(ans, minLca[a][l]);
      ans = min(ans, minLca[b][l]);
      a = lca[a][l];
      b = lca[b][l];
    }
  }
  ans = min(ans, minLca[a][0]);
  ans = min(ans, minLca[b][0]);
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> w[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    graph[a].emplace_back(b, i);
    graph[b].emplace_back(a, i);
    edges[i] = {a, b};
  }
  cin >> s;
  priority_queue<pair<int, pair<int, int> > > pq;
  pq.push({0, {1, -1}});
  vector<int> used;
  while (!pq.empty()) {
    auto au = pq.top();
    pq.pop();
    int x = au.second.first;
    int edge = au.second.second;
    if (vis[x]) {
      continue;
    }
    vis[x] = 1;
    if (edge == -1) {
      dep[x] = 1;
    } else {
      topEdge[x] = edge;
      us[edge] = 1;
      used.push_back(edge);
      lca[x][0] = x ^ edges[edge].first ^ edges[edge].second;
      minLca[x][0] = -w[edge];
      dep[x] = dep[lca[x][0]] + 1;
      for (int i = 1; i < K; i++) {
        lca[x][i] = lca[lca[x][i - 1]][i - 1];
        minLca[x][i] = min(minLca[x][i - 1], minLca[lca[x][i - 1]][i - 1]);
      }
    }
    for (auto pr : graph[x]) {
      int next = pr.first;
      int weight = w[pr.second];
      pq.push({-weight, {next, pr.second}});
    }
  }
  long long total = 0;
  for (int x : used) {
    total += w[x];
  }
  long long best = total + 1;
  long long which = -1;
  for (int i = 0; i < m; i++) {
    long long here;
    if (us[i]) {
      here = total - (s / c[i]);
    } else {
      long long hereBase =
          total + w[i] + getMin(edges[i].first, edges[i].second);
      here = hereBase - (s / c[i]);
    }
    if (here < best) {
      best = here;
      which = i;
    }
  }
  cout << best << "\n";
  long long save = s / c[which];
  if (us[which]) {
    for (int e : used) {
      if (e == which) {
        cout << e + 1 << " " << w[e] - save << "\n";
      } else {
        cout << e + 1 << " " << w[e] << "\n";
      }
    }
  } else {
    int a = edges[which].first;
    int b = edges[which].second;
    if (dep[a] < dep[b]) {
      swap(a, b);
    }
    int mn = 1e9;
    int th = -1;
    while (dep[a] > dep[b]) {
      if (-w[topEdge[a]] < mn) {
        mn = -w[topEdge[a]];
        th = topEdge[a];
      }
      a = lca[a][0];
    }
    while (a != b) {
      if (-w[topEdge[a]] < mn) {
        mn = -w[topEdge[a]];
        th = topEdge[a];
      }
      a = lca[a][0];
      if (-w[topEdge[b]] < mn) {
        mn = -w[topEdge[b]];
        th = topEdge[b];
      }
      b = lca[b][0];
    }
    cout << which + 1 << " " << w[which] - save << "\n";
    for (int x : used) {
      if (x == th) {
        continue;
      }
      cout << x + 1 << " " << w[x] << "\n";
    }
  }
}
