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;
long long n, m, s;
struct tree {
  long long w, id;
  tree operator+(const tree &a) const {
    tree c;
    if (a.w > w)
      c.w = a.w, c.id = a.id;
    else
      c.w = w, c.id = id;
    return c;
  }
} TR[1000005];
struct Node {
  long long u, v, w, id, tag, nex;
} Edge[400005], Edge_inv[200005];
bool cmp(Node a, Node b) { return a.w < b.w; }
long long h[200005], stot;
void add(long long u, long long v, long long w, long long id) {
  Edge[++stot] = (Node){u, v, w, id, 0, h[u]};
  h[u] = stot;
}
long long stot_inv;
void add_inv(long long u, long long v, long long w, long long id) {
  Edge_inv[++stot_inv] = (Node){u, v, w, id, 0, 0};
}
long long fa[200005], dep[200005], siz[200005], son[200005], sw[200005],
    sid[200005];
void dfs1(long long u, long long f) {
  fa[u] = f;
  dep[u] = dep[f] + 1;
  siz[u] = 1;
  for (long long i = h[u]; i; i = Edge[i].nex) {
    long long v = Edge[i].v;
    if (v == f) continue;
    dfs1(v, u);
    siz[u] += siz[v];
    if (siz[v] > siz[son[u]])
      son[u] = v, sw[u] = Edge[i].w, sid[u] = Edge[i].id;
  }
}
long long top[200005], seq[200005], seq1[200005], in[200005], idc;
void dfs2(long long u, long long t, long long w, long long id) {
  top[u] = t;
  seq[++idc] = w;
  seq1[idc] = id, in[u] = idc;
  if (son[u]) dfs2(son[u], t, sw[u], sid[u]);
  for (long long i = h[u]; i; i = Edge[i].nex) {
    long long v = Edge[i].v;
    if (v == fa[u] || v == son[u]) continue;
    dfs2(v, v, Edge[i].w, Edge[i].id);
  }
}
void update(long long nd) { TR[nd] = TR[nd << 1] + TR[nd << 1 | 1]; }
void build(long long nd, long long l, long long r) {
  if (l == r) {
    TR[nd].w = seq[l];
    TR[nd].id = seq1[l];
    return;
  }
  long long mid = (l + r) >> 1;
  build(nd << 1, l, mid);
  build(nd << 1 | 1, mid + 1, r);
  update(nd);
}
tree query(long long nd, long long l, long long r, long long L, long long R) {
  if (l >= L && r <= R) return TR[nd];
  long long mid = (l + r) >> 1;
  tree ans;
  ans.w = -0x3f3f3f3f, ans.id = 0;
  if (L <= mid) ans = ans + query(nd << 1, l, mid, L, R);
  if (R > mid) ans = ans + query(nd << 1 | 1, mid + 1, r, L, R);
  return ans;
}
tree query(long long u, long long v) {
  tree ans;
  ans.w = -0x3f3f3f3f, ans.id = 0;
  while (top[u] != top[v]) {
    if (dep[top[u]] < dep[top[v]]) swap(u, v);
    ans = ans + query(1, 1, n, in[top[u]], in[u]);
    u = fa[top[u]];
  }
  if (dep[u] < dep[v]) swap(u, v);
  ans = ans + query(1, 1, n, in[v] + 1, in[u]);
  return ans;
}
long long f[200005];
long long find(long long x) {
  if (x != f[x]) f[x] = find(f[x]);
  return f[x];
}
long long w[200005], c[200005], tot, ans1, ans2;
void Kruskal() {
  sort(Edge_inv + 1, Edge_inv + 1 + m, cmp);
  for (long long i = 1; i <= n; i++) f[i] = i;
  for (long long i = 1; i <= m; i++) {
    long long u = Edge_inv[i].u, v = Edge_inv[i].v, id = Edge_inv[i].id;
    long long uu = find(u), vv = find(v);
    if (uu != vv) {
      Edge_inv[i].tag = 1;
      f[uu] = vv;
      add(u, v, w[id], id);
      add(v, u, w[id], id);
      tot += w[id];
      if (c[id] < c[ans1]) ans1 = id;
    }
  }
}
int main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= m; i++) scanf("%lld", &w[i]);
  for (long long i = 1; i <= m; i++) scanf("%lld", &c[i]);
  c[0] = 0x3f3f3f3f;
  for (long long i = 1; i <= m; i++) {
    long long u, v;
    scanf("%lld%lld", &u, &v);
    add_inv(u, v, w[i], i);
  }
  scanf("%lld", &s);
  Kruskal();
  ans2 = tot - s / c[ans1];
  dfs1(1, 0);
  dfs2(1, 0, -0x3f3f3f3f, 0);
  build(1, 1, n);
  long long flag = 0;
  for (long long i = 1; i <= m; i++) {
    if (!Edge_inv[i].tag) {
      long long u = Edge_inv[i].u, v = Edge_inv[i].v, id = Edge_inv[i].id;
      tree a = query(u, v);
      long long tmp = tot - a.w + w[id] - s / c[id];
      if (tmp < ans2) ans1 = id, ans2 = tmp, flag = a.id;
    }
  }
  printf("%lld\n", ans2);
  for (long long i = 1; i <= m; i++) {
    long long id = Edge_inv[i].id;
    if (ans1 == id) {
      printf("%lld %lld\n", id, w[id] - s / c[id]);
    } else if (Edge_inv[i].tag) {
      if (flag != id) {
        printf("%lld %lld\n", id, w[id]);
      }
    }
  }
  return 0;
}