Problem: In one kingdom there are n cities and m two-way roads. Each road connects a pair of cities, and for each road we know the level of drivers dissatisfaction — the value wi.

For each road we know the value ci — how many lamziks we should spend to reduce the level of dissatisfaction with this road by one. Thus, to reduce the dissatisfaction with the i-th road by k, we should spend k·ci lamziks. And it is allowed for the dissatisfaction to become zero or even negative.

In accordance with the king's order, we need to choose n - 1 roads and make them the main roads. An important condition must hold: it should be possible to travel from any city to any other by the main roads.

The road ministry has a budget of S lamziks for the reform. The ministry is going to spend this budget for repair of some roads (to reduce the dissatisfaction with them), and then to choose the n - 1 main roads.

Help to spend the budget in such a way and then to choose the main roads so that the total dissatisfaction with the main roads will be as small as possible. The dissatisfaction with some roads can become negative. It is not necessary to spend whole budget S.

It is guaranteed that it is possible to travel from any city to any other using existing roads. Each road in the kingdom is a two-way road.

Input

The first line contains two integers n and m (2 ≤ n ≤ 2·105, n - 1 ≤ m ≤ 2·105) — the number of cities and the number of roads in the kingdom, respectively.

The second line contains m integers w1, w2, ..., wm (1 ≤ wi ≤ 109), where wi is the drivers dissatisfaction with the i-th road.

The third line contains m integers c1, c2, ..., cm (1 ≤ ci ≤ 109), where ci is the cost (in lamziks) of reducing the dissatisfaction with the i-th road by one.

The next m lines contain the description of the roads. The i-th of this lines contain a pair of integers ai and bi (1 ≤ ai, bi ≤ n, ai ≠ bi) which mean that the i-th road connects cities ai and bi. All roads are two-way oriented so it is possible to move by the i-th road from ai to bi, and vice versa. It is allowed that a pair of cities is connected by more than one road. 

The last line contains one integer S (0 ≤ S ≤ 109) — the number of lamziks which we can spend for reforms. 

Output

In the first line print K — the minimum possible total dissatisfaction with main roads.

In each of the next n - 1 lines print two integers x, vx, which mean that the road x is among main roads and the road x, after the reform, has the level of dissatisfaction vx.

Consider that roads are numbered from 1 to m in the order as they are given in the input data. The edges can be printed in arbitrary order. If there are several answers, print any of them. 

Examples

Input

6 9
1 3 1 1 3 1 2 2 2
4 1 4 2 2 5 3 1 6
1 2
1 3
2 3
2 4
2 5
3 5
3 6
4 5
5 6
7


Output

0
1 1
3 1
6 1
7 2
8 -5


Input

3 3
9 5 1
7 7 2
2 1
3 1
3 2
2


Output

5
3 0
2 5

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline int read(T& x) {
  x = 0;
  char c = getchar(), f = 1;
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    if (c == -1) return -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0')
    x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  x *= f;
  return 1;
}
template <typename T, typename... Args>
inline int read(T& x, Args&... args) {
  return read(x) + read(args...);
}
template <typename T>
inline int write(T x) {
  if (x < 0) return putchar('-') & write((~x) + 1);
  if (x / 10) return write(x / 10) & putchar(x % 10 | 48);
  return putchar(x | 48);
}
template <typename T>
inline int write(T x, char c) {
  return write(x) + putchar(c);
}
long long n, m;
long long s;
struct edge {
  long long v, nxt;
  long long w;
} e[400005 << 1];
struct node {
  long long u, v, id;
  long long w, c;
  inline node() {}
  inline node(long long u, long long v, long long w) : u(u), v(v), w(w) {}
  inline bool operator<(const node& rhs) const { return w < rhs.w; }
} k[400005];
long long c[400005];
long long tot, f[400005];
inline void addEdge(long long u, long long v, long long w) {
  tot++, e[tot].v = v, e[tot].w = w, e[tot].nxt = f[u], f[u] = tot;
}
long long fa[400005];
inline void init() {
  for (long long i = 1; i <= n; i++) fa[i] = i;
}
inline long long findSet(long long x) {
  while (x != fa[x]) x = fa[x] = fa[fa[x]];
  return x;
}
long long minc = INT_MAX;
inline long long Kruskal() {
  init();
  sort(k + 1, k + m + 1);
  long long cnt = 0;
  long long mst = 0;
  for (long long i = 1; i <= m; i++) {
    if (findSet(k[i].u) != findSet(k[i].v)) {
      fa[findSet(k[i].u)] = findSet(k[i].v);
      cnt++;
      mst += k[i].w;
      minc = ((minc) < (k[i].c) ? (minc) : (k[i].c));
      addEdge(k[i].u, k[i].v, k[i].w);
      addEdge(k[i].v, k[i].u, k[i].w);
    }
    if (cnt == n - 1) break;
  }
  return mst;
}
long long dep[400005], p[400005][20];
long long w[400005][20];
inline void dfs(long long x, long long fa, long long prw) {
  p[x][0] = fa, w[x][0] = prw;
  dep[x] = dep[fa] + 1;
  for (long long i = 1; i < 20; i++) {
    p[x][i] = p[p[x][i - 1]][i - 1];
    w[x][i] =
        ((w[x][i - 1]) > (w[p[x][i - 1]][i - 1]) ? (w[x][i - 1])
                                                 : (w[p[x][i - 1]][i - 1]));
  }
  for (long long i = f[x]; i; i = e[i].nxt)
    if (e[i].v != fa) dfs(e[i].v, x, e[i].w);
}
inline long long lca(long long a, long long b) {
  long long ans = 0;
  if (dep[a] < dep[b]) swap(a, b);
  for (long long i = 19; i >= 0; i--) {
    if (dep[p[a][i]] >= dep[b])
      ans = ((ans) > (w[a][i]) ? (ans) : (w[a][i])), a = p[a][i];
  }
  if (a == b) return ans;
  for (long long i = 19; i >= 0; i--) {
    if (p[a][i] == p[b][i]) continue;
    ans = ((ans) > (((w[a][i]) > (w[b][i]) ? (w[a][i]) : (w[b][i])))
               ? (ans)
               : (((w[a][i]) > (w[b][i]) ? (w[a][i]) : (w[b][i]))));
    a = p[a][i], b = p[b][i];
  }
  return ((ans) > (((w[a][0]) > (w[b][0]) ? (w[a][0]) : (w[b][0])))
              ? (ans)
              : (((w[a][0]) > (w[b][0]) ? (w[a][0]) : (w[b][0]))));
}
signed main() {
  read(n, m);
  for (long long i = 1; i <= m; i++) read(k[i].w);
  for (long long i = 1; i <= m; i++) read(k[i].c);
  for (long long i = 1; i <= m; i++) {
    read(k[i].u, k[i].v);
    k[i].id = i;
  }
  read(s);
  long long mst = Kruskal();
  dfs(1, 0, 0);
  long long ansid = 0, ans = mst - s / minc;
  for (long long i = 1; i <= m; i++) {
    if (k[i].c <= minc) {
      long long t = mst + k[i].w - lca(k[i].u, k[i].v) - s / k[i].c;
      if (ans >= t) ans = t, ansid = i;
    }
  }
  write(ans, '\n');
  swap(k[ansid], k[1]);
  sort(k + 2, k + m + 1);
  init();
  fa[k[1].u] = k[1].v;
  write(k[1].id, ' '), write(k[1].w - s / k[1].c, '\n');
  long long cnt = 1;
  for (long long i = 2; i <= m; i++) {
    long long x = findSet(k[i].u), y = findSet(k[i].v);
    if (x != y) {
      fa[x] = y;
      write(k[i].id, ' '), write(k[i].w, '\n');
      cnt++;
    }
    if (cnt == n - 1) break;
  }
}