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;
int N, M, S, C;
long long w[200005], c[200005];
struct Edge {
  int u, v, w;
  bool f;
  int id;
  Edge(int u = 0, int v = 0, int w = 0, int id = 0)
      : u(u), v(v), w(w), id(id) {}
  bool operator<(const Edge& e1) const { return w < e1.w; }
} eList[200005];
vector<Edge> Adj[200005];
int p[200005];
int findR(int x) {
  if (p[x] == x)
    return x;
  else
    return p[x] = findR(p[x]);
}
long long ans0 = 0;
void kruskal() {
  for (int i = 1; i <= N; i++) p[i] = i;
  sort(eList + 1, eList + 1 + M);
  int cnt = 0;
  int u, v, w, ru, rv;
  for (int i = 1; i <= M; i++) {
    u = eList[i].u;
    v = eList[i].v;
    w = eList[i].w;
    ru = findR(u);
    rv = findR(v);
    eList[i].f = 0;
    if (ru == rv) continue;
    cnt++;
    p[ru] = rv;
    ans0 += w;
    int id = eList[i].id;
    Adj[u].push_back(Edge(u, v, w, id));
    Adj[v].push_back(Edge(v, u, w, id));
    eList[i].f = 1;
    if (cnt == N - 1) break;
  }
}
int depth[200005];
int anc[200005][25];
int maxW[200005][25];
bool vis[200005];
void dfs(int u) {
  vis[u] = 1;
  for (int j = 1; j <= 20; j++) {
    if (depth[u] <= (1 << j)) break;
    anc[u][j] = anc[anc[u][j - 1]][j - 1];
    maxW[u][j] = max(maxW[u][j - 1], maxW[anc[u][j - 1]][j - 1]);
  }
  int v, w;
  for (int k = 0; k < Adj[u].size(); k++) {
    v = Adj[u][k].v;
    w = Adj[u][k].w;
    if (vis[v]) continue;
    depth[v] = depth[u] + 1;
    anc[v][0] = u;
    maxW[v][0] = w;
    dfs(v);
  }
  return;
}
int lca(int u, int v) {
  if (depth[u] < depth[v]) swap(u, v);
  for (int j = 20; j >= 0; j--) {
    if (depth[anc[u][j]] >= depth[v]) {
      u = anc[u][j];
    }
  }
  if (u == v) return u;
  for (int j = 20; j >= 0; j--) {
    if (anc[u][j] != anc[v][j]) {
      u = anc[u][j];
      v = anc[v][j];
    }
  }
  return anc[u][0];
}
long long maxS(int id) { return S / c[id]; }
int u1 = -1, v1 = -1;
int ansid = -1;
void dfs2(int u) {
  vis[u] = 1;
  int v, w, id;
  for (int k = 0; k < Adj[u].size(); k++) {
    v = Adj[u][k].v;
    w = Adj[u][k].w;
    id = Adj[u][k].id;
    if (vis[v]) continue;
    dfs2(v);
    if (u == u1 && v == v1 || v == u1 && u == v1) continue;
    if (id == ansid) {
      cout << id << " " << w - maxS(id) << endl;
    } else {
      cout << id << " " << w << endl;
    }
  }
  return;
}
int jumpUP(int u, int z) {
  int ans = 0;
  for (int j = 20; j >= 0; j--) {
    if (depth[anc[u][j]] >= depth[z]) {
      ans = max(ans, maxW[u][j]);
      u = anc[u][j];
    }
  }
  return ans;
}
int query(int u, int v) {
  int z = lca(u, v);
  return max(jumpUP(u, z), jumpUP(v, z));
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 1; i <= M; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= M; i++) scanf("%d", &c[i]);
  int u, v;
  for (int i = 1; i <= M; i++) {
    scanf("%d%d", &u, &v);
    eList[i] = Edge(u, v, w[i], i);
    eList[i].f = 0;
  }
  kruskal();
  scanf("%d", &S);
  depth[1] = 1;
  anc[1][0] = 1;
  dfs(1);
  long long ans1 = ans0;
  long long ans = ans0;
  int id;
  for (int i = 1; i <= M; i++) {
    id = eList[i].id;
    u = eList[i].u;
    v = eList[i].v;
    if (eList[i].f) {
      ans1 = ans0 - maxS(id);
    } else {
      ans1 = ans0 - query(u, v) + w[id] - maxS(id);
    }
    if (ans1 < ans) {
      ans = ans1;
      ansid = id;
    }
  }
  cout << ans << endl;
  if (ansid != -1) {
    for (int i = 1; i <= M; i++) {
      if (ansid == eList[i].id) {
        u = eList[i].u;
        v = eList[i].v;
        break;
      }
    }
    int w1 = query(u, v);
    int z = lca(u, v);
    int p;
    p = u;
    while (p != z) {
      if (maxW[p][0] == w1) {
        u1 = anc[p][0];
        v1 = p;
      }
      p = anc[p][0];
    }
    p = v;
    while (p != z) {
      if (maxW[p][0] == w1) {
        u1 = anc[p][0];
        v1 = p;
      }
      p = anc[p][0];
    }
  }
  memset(vis, 0, sizeof(vis));
  dfs2(1);
  if (ansid != -1) {
    cout << ansid << " " << w[ansid] - maxS(ansid) << endl;
  }
  return 0;
}