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 initial[200005], size[200005];
int root(int i) {
  while (initial[i] != i) {
    initial[i] = initial[initial[i]];
    i = initial[i];
  }
  return i;
}
void weighted_union(int x, int y) {
  int root1 = root(x), root2 = root(y);
  if (size[root1] < size[root2]) {
    initial[root1] = root2;
    size[root2] += size[root1];
  } else {
    initial[root2] = root1;
    size[root1] += size[root2];
  }
}
vector<pair<pair<int, int>, pair<int, int> > > vec;
vector<pair<int, int> > adj[200005];
long long ans[200005];
bool visited[200005];
int F[200005], L[200005];
int DP[18][200005], AT[18][200005], lg[200005];
void dfs(int x) {
  visited[x] = true;
  for (int i = 0; i < adj[x].size(); i++) {
    if (!visited[adj[x][i].first]) {
      DP[0][adj[x][i].first] = adj[x][i].second;
      L[adj[x][i].first] = 1 + L[x];
      F[adj[x][i].first] = x;
      AT[0][adj[x][i].first] = x;
      dfs(adj[x][i].first);
    }
  }
}
int P[18][200005];
void preLCA(int N) {
  int i, j;
  for (i = 1; i <= N; i++)
    for (j = 0; 1 << j < N; j++) P[j][i] = -1;
  for (i = 1; i <= N; i++) P[0][i] = F[i];
  for (j = 1; 1 << j < N; j++)
    for (i = 1; i <= N; i++)
      if (P[j - 1][i] != -1) P[j][i] = P[j - 1][P[j - 1][i]];
}
int LCA(int p, int q) {
  int tmp, log, i;
  if (L[p] < L[q]) tmp = p, p = q, q = tmp;
  for (log = 1; 1 << log <= L[p]; log++)
    ;
  log--;
  for (i = log; i >= 0; i--)
    if (L[p] - (1 << i) >= L[q]) p = P[i][p];
  if (p == q) return p;
  for (i = log; i >= 0; i--)
    if (P[i][p] != -1 && P[i][p] != P[i][q]) p = P[i][p], q = P[i][q];
  return F[p];
}
void pathdata(int n) {
  for (int i = 1; i < 18; i++) {
    for (int j = 1; j <= n; j++) {
      DP[i][j] = max(DP[i - 1][j], DP[i - 1][AT[i - 1][j]]);
      AT[i][j] = AT[i - 1][AT[i - 1][j]];
    }
  }
  for (int p = 0; p < 18; p++) {
    int s = 1 << p, e = min((1 << (p + 1)) - 1, n);
    for (int i = s; i <= e; i++) lg[i] = p;
  }
}
int process(int u, int v) {
  int x = LCA(u, v);
  int mx1 = 0, mx2 = 0;
  int p = L[u] - L[x];
  while (p) {
    int t = lg[p];
    mx1 = max(mx1, DP[t][u]);
    u = AT[t][u];
    p -= 1 << t;
  }
  p = L[v] - L[x];
  while (p) {
    int t = lg[p];
    mx2 = max(mx2, DP[t][v]);
    v = AT[t][v];
    p -= 1 << t;
  }
  return max(mx1, mx2);
}
int w[200005], c[200005];
bool stats[200005];
vector<pair<int, int> > adj2[200005];
bool ok[200005];
void dfs(int u, int v) {
  visited[u] = true;
  if (u == v) {
    ok[u] = true;
    return;
  }
  for (int j = 0; j < adj2[u].size(); j++) {
    int ch = adj2[u][j].first;
    if (visited[ch]) continue;
    dfs(ch, v);
    if (ok[ch]) {
      ok[u] = true;
    }
  }
}
int go(int u, int v) {
  int mn = -1000000007;
  int ret;
  memset(visited, 0, sizeof(visited));
  while (u != v) {
    visited[u] = true;
    for (int j = 0; j < adj2[u].size(); j++) {
      int ch = adj2[u][j].first;
      if (visited[ch]) continue;
      if (ok[ch]) {
        int ind = adj2[u][j].second;
        if (w[ind] > mn) {
          mn = w[ind];
          ret = ind;
        }
        u = ch;
        break;
      }
    }
  }
  return ret;
}
int main() {
  int n, m;
  scanf("%d", &n);
  scanf("%d", &m);
  for (int i = 1; i <= n; i++) {
    initial[i] = i;
    size[i] = 1;
  }
  memset(stats, 0, sizeof(stats));
  for (int i = 1; i <= m; i++) scanf("%d", &w[i]);
  for (int i = 1; i <= m; i++) scanf("%d", &c[i]);
  for (int i = 1; i <= m; i++) {
    int u, v;
    scanf("%d", &u);
    scanf("%d", &v);
    vec.push_back(make_pair(make_pair(w[i], i), make_pair(u, v)));
  }
  int s;
  scanf("%d", &s);
  sort(vec.begin(), vec.end());
  long long original = 0;
  for (int i = 0; i < vec.size(); i++) {
    int u = vec[i].second.first, v = vec[i].second.second;
    if (root(u) == root(v)) continue;
    weighted_union(u, v);
    stats[vec[i].first.second] = true;
    int w = vec[i].first.first;
    original += w;
    adj[u].push_back(make_pair(v, w));
    adj2[u].push_back(make_pair(v, vec[i].first.second));
    adj[v].push_back(make_pair(u, w));
    adj2[v].push_back(make_pair(u, vec[i].first.second));
  }
  memset(visited, 0, sizeof(visited));
  memset(DP, 0, sizeof(DP));
  memset(AT, 0, sizeof(AT));
  F[1] = -1;
  L[1] = 0;
  dfs(1);
  preLCA(n);
  pathdata(n);
  for (int i = 0; i < vec.size(); i++) {
    int u = vec[i].second.first, v = vec[i].second.second;
    if ((F[u] == v || F[v] == u) && stats[vec[i].first.second]) {
      int ind = vec[i].first.second;
      ans[ind] = original;
      ans[ind] -= s / c[ind];
      continue;
    }
    int ind = vec[i].first.second;
    ans[ind] = original;
    ans[ind] += w[ind] - s / c[ind];
    ans[ind] -= process(u, v);
  }
  long long mn = 1000000007 * 1LL * 1000000007;
  int ind;
  for (int i = 1; i <= m; i++) {
    if (ans[i] < mn) {
      mn = ans[i];
      ind = i;
    }
  }
  printf("%lld\n", mn);
  for (int i = 0; i < vec.size(); i++) {
    int now_ind = vec[i].first.second;
    if (now_ind != ind) continue;
    int u = vec[i].second.first, v = vec[i].second.second;
    if ((F[u] == v || F[v] == u) && stats[vec[i].first.second]) {
      w[ind] -= s / c[ind];
      continue;
    }
    stats[ind] = true;
    w[ind] -= s / c[ind];
    memset(visited, 0, sizeof(visited));
    memset(ok, 0, sizeof(ok));
    dfs(u, v);
    int ind2 = go(u, v);
    stats[ind2] = false;
  }
  for (int i = 1; i <= m; i++) {
    if (stats[i]) {
      printf("%d %d\n", i, w[i]);
    }
  }
}