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;
const long long INF = 1e18;
const long long mod = 1e9 + 7;
const long long maxn = 2e5 + 10;
const long long K = 755;
long long n, m;
long long p[maxn], h[maxn], par[maxn][22], s[maxn][22], w[maxn];
vector<pair<long long, long long>> g[maxn];
void dfs(long long u) {
  s[u][0] = w[u];
  par[u][0] = p[u];
  for (long long i = 1; (1 << i) <= h[u]; i++) {
    par[u][i] = par[par[u][i - 1]][i - 1];
    s[u][i] = max(s[par[u][i - 1]][i - 1], s[u][i - 1]);
  }
  for (long long i = 0; i < g[u].size(); i++)
    if (g[u][i].first != p[u]) {
      h[g[u][i].first] = h[u] + 1;
      p[g[u][i].first] = u;
      w[g[u][i].first] = g[u][i].second;
      dfs(g[u][i].first);
    }
}
long long get_par(long long u, long long he) {
  if (he == 0) return u;
  if (he == 1) return par[u][0];
  long long x = log2(he);
  return get_par(par[u][x], he - (1 << x));
}
long long get_max(long long u, long long he) {
  if (he == 0) return 0;
  if (he == 1) return s[u][0];
  long long x = log2(he);
  return max(get_max(par[u][x], he - (1 << x)), s[u][x]);
}
long long get_lca(long long u, long long v) {
  long long ans = 0;
  if (h[v] < h[u]) swap(u, v);
  long long he = h[v] - h[u];
  ans = max(ans, get_max(v, he));
  v = get_par(v, he);
  if (u == v) return ans;
  if (p[v] == p[u]) return max(ans, max(w[u], w[v]));
  long long x = 0;
  while (par[u][x] != par[v][x]) x++;
  x--;
  ans = max(ans, max(s[u][x], s[v][x]));
  u = par[u][x];
  v = par[v][x];
  return max(get_lca(u, v), ans);
}
long long siz[maxn], dsu_par[maxn];
long long dsu_get_par(long long u) {
  while (dsu_par[u] != u) u = dsu_par[u];
  return u;
}
void dsu(long long u, long long v) {
  u = dsu_get_par(u);
  v = dsu_get_par(v);
  if (siz[v] < siz[u]) swap(u, v);
  dsu_par[u] = v;
  siz[v] += siz[u];
}
vector<pair<long long, pair<long long, long long>>> edge, edge1;
long long ww[maxn];
long long c[maxn];
int main() {
  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  cin >> n >> m;
  for (long long i = 0; i < m; i++) cin >> ww[i];
  for (long long i = 0; i < m; i++) cin >> c[i];
  for (long long i = 0; i < m; i++) {
    long long u, v;
    cin >> u >> v;
    edge.push_back({ww[i], {u, v}});
    edge1.push_back({ww[i], {u, v}});
  }
  sort(edge.begin(), edge.end());
  for (long long i = 1; i <= n; i++) {
    dsu_par[i] = i;
    siz[i] = 1;
  }
  long long bud;
  cin >> bud;
  long long mst = 0;
  for (long long i = 0; i < m; i++) {
    long long u = edge[i].second.first;
    long long v = edge[i].second.second;
    long long w2 = edge[i].first;
    if (dsu_get_par(u) != dsu_get_par(v)) {
      dsu(u, v);
      mst += w2;
      g[v].push_back({u, w2});
      g[u].push_back({v, w2});
    }
  }
  dfs(1);
  long long ans = 1e18, road, haz;
  for (long long i = 0; i < m; i++) {
    long long u = edge1[i].second.first;
    long long v = edge1[i].second.second;
    long long w2 = edge1[i].first;
    long long x = get_lca(u, v);
    long long me = mst - x + w2;
    long long S = bud / c[i];
    if (me - S < ans) {
      ans = me - S;
      road = i;
      haz = ww[i] - S;
    }
  }
  vector<pair<pair<long long, long long>, pair<long long, long long>>> ve;
  for (long long i = 0; i < edge1.size(); i++) {
    long long u = edge1[i].second.first;
    long long v = edge1[i].second.second;
    long long w2 = edge1[i].first;
    ve.push_back({{w2, i}, {u, v}});
  }
  sort(ve.begin(), ve.end());
  for (long long i = 1; i <= n; i++) {
    siz[i] = 1;
    dsu_par[i] = i;
  }
  vector<long long> mstt;
  dsu(edge1[road].second.first, edge1[road].second.second);
  mstt.push_back(road);
  for (long long i = 0; i < m; i++) {
    long long u = ve[i].second.first;
    long long v = ve[i].second.second;
    long long w2 = ve[i].first.first;
    if (dsu_get_par(u) != dsu_get_par(v)) {
      mstt.push_back(ve[i].first.second);
      dsu(u, v);
    }
  }
  cout << ans << "\n";
  sort(mstt.begin(), mstt.end());
  for (long long i = 0; i < mstt.size(); i++) {
    if (mstt[i] == road)
      cout << mstt[i] + 1 << " " << haz << "\n";
    else
      cout << mstt[i] + 1 << " " << ww[mstt[i]] << "\n";
  }
}