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 int N, M, S;
const long long int MAX = 200020;
struct Edge {
  long long int u;
  long long int v;
  long long int w;
  long long int c;
  long long int idx;
  Edge(){};
};
Edge es[MAX];
bool compare(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
inline long long int other(long long int u, const Edge &e) {
  return e.u + e.v - u;
}
long long int _cl[MAX];
long long int cl(long long int i) {
  return (_cl[i] == -1 ? i : _cl[i] = cl(_cl[i]));
}
void join(long long int i, long long int j) {
  if (cl(i) != cl(j)) _cl[cl(i)] = cl(j);
}
bool inMst[MAX];
vector<Edge> mst[MAX];
const long long int maxE = 20;
long long int up[MAX][maxE];
long long int height[MAX];
Edge maxi[MAX][maxE];
void dfs(long long int p, long long int v, const Edge &e0) {
  height[v] = v == 0 ? 0 : height[p] + 1;
  up[v][0] = p;
  for (long long int i = 0; i < (long long int)maxE - 1; i++)
    up[v][i + 1] = up[up[v][i]][i];
  maxi[v][0] = e0;
  for (long long int i = 0; i < (long long int)maxE - 1; i++)
    maxi[v][i + 1] = max(maxi[v][i], maxi[up[v][i]][i], compare);
  for (auto e : mst[v]) {
    long long int u = other(v, e);
    if (u != p) {
      dfs(v, u, e);
    }
  }
}
long long int lca(long long int u, long long int v) {
  if (height[u] < height[v]) swap(u, v);
  long long int delta = height[u] - height[v];
  assert(delta >= 0);
  for (long long int i = 0; i < (long long int)maxE; i++)
    if (delta >> i & 1) u = up[u][i];
  assert(height[u] == height[v]);
  if (u == v) return u;
  for (long long int i = (long long int)(maxE)-1; i >= 0; i--) {
    if (up[u][i] != up[v][i]) u = up[u][i], v = up[v][i];
  }
  assert(up[u][0] == up[v][0]);
  assert(u != v);
  return up[u][0];
}
Edge maxToAncestor(long long int u, long long int z) {
  long long int delta = height[u] - height[z];
  assert(delta >= 0);
  Edge res;
  res.w = -1;
  for (long long int i = 0; i < (long long int)maxE; i++)
    if (delta >> i & 1) {
      res = max(res, maxi[u][i], compare);
      u = up[u][i];
    }
  assert(u == z);
  return res;
}
Edge maxiOnPath(long long int u, long long int v) {
  long long int z = lca(u, v);
  return max(maxToAncestor(u, z), maxToAncestor(v, z), compare);
}
const long long int INF = 1e18;
void solve() {
  for (long long int i = 0; i < (long long int)M; i++) es[i].idx = i;
  for (long long int i = 0; i < (long long int)M; i++) cin >> es[i].w;
  for (long long int i = 0; i < (long long int)M; i++) cin >> es[i].c;
  for (long long int i = 0; i < (long long int)M; i++) {
    cin >> es[i].u >> es[i].v;
    es[i].u--, es[i].v--;
  }
  cin >> S;
  sort(es, es + M, compare);
  for (long long int i = 0; i < (long long int)N; i++)
    _cl[i] = -1, inMst[i] = false;
  long long int mstCost = 0;
  for (long long int i = 0; i < (long long int)M; i++) {
    Edge e = es[i];
    long long int u = e.u, v = e.v;
    if (cl(u) != cl(v)) {
      inMst[i] = true;
      join(u, v);
      mst[u].push_back(e);
      mst[v].push_back(e);
      mstCost += e.w;
    }
  }
  Edge e0;
  e0.u = 0;
  e0.v = 0;
  e0.w = -1;
  e0.idx = -1;
  dfs(0, 0, e0);
  long long int res = INF;
  long long int best_e_special = -1;
  long long int best_e_remove = -1;
  for (long long int i = 0; i < (long long int)M; i++) {
    Edge e_special = es[i];
    if (inMst[i]) {
      long long int newCost = mstCost - S / e_special.c;
      if (res > newCost) {
        res = newCost;
        best_e_special = e_special.idx;
        best_e_remove = -1;
      }
    } else {
      Edge e_remove = maxiOnPath(e_special.u, e_special.v);
      long long int newCost =
          mstCost + e_special.w - S / e_special.c - e_remove.w;
      if (res > newCost) {
        res = newCost;
        best_e_remove = e_remove.idx;
        best_e_special = e_special.idx;
      }
    }
  }
  cout << res << endl;
  if (best_e_remove == -1) {
    for (long long int i = 0; i < (long long int)M; i++) {
      Edge e = es[i];
      if (inMst[i]) {
        if (e.idx == best_e_special) {
          cout << e.idx + 1 << " " << e.w - S / e.c << endl;
        } else {
          cout << e.idx + 1 << " " << e.w << endl;
        }
      }
    }
  } else {
    assert(best_e_remove != -1);
    for (long long int i = 0; i < (long long int)M; i++) {
      Edge e = es[i];
      if (inMst[i] && best_e_remove != e.idx) {
        cout << e.idx + 1 << " " << e.w << endl;
      }
      if (e.idx == best_e_special) {
        cout << e.idx + 1 << " " << e.w - S / e.c << endl;
      }
    }
  }
}
int main() {
  while (cin >> N >> M) {
    solve();
  }
  return 0;
}