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>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long long mod = 1e9 + 7;
struct edge {
  int u, v;
  long long w, c;
  int in;
};
bool comp(edge a, edge b) { return a.w < b.w; }
int n;
vector<int> p, rang;
void make_set(int v) {
  p[v] = v;
  rang[v] = 1;
}
int find_set(int v) {
  if (v == p[v]) return v;
  return p[v] = find_set(p[v]);
}
void union_set(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (rang[a] < rang[b]) swap(a, b);
    p[b] = a;
    rang[a] += rang[b];
  }
}
vector<int> h;
const int logN = 19;
const long long INF = LONG_LONG_MAX;
vector<vector<pair<int, long long> > > g, dp;
void dfs(int v, int p, int height) {
  dp[v][0].first = p;
  h[v] = height;
  for (int j = 0; j < g[v].size(); j++) {
    int to = g[v][j].first;
    if (to != p) {
      dp[to][0].second = g[v][j].second;
      dfs(to, v, height + 1);
    }
  }
}
void preprocess() {
  for (int j = 1; j < logN; j++) {
    for (int i = 0; i < n; i++) {
      dp[i][j].first = dp[dp[i][j - 1].first][j - 1].first;
      dp[i][j].second =
          max(dp[i][j - 1].second, dp[dp[i][j - 1].first][j - 1].second);
    }
  }
}
long long max_dissat(int u, int v) {
  if (h[u] < h[v]) swap(u, v);
  long long max_edge = -INF;
  for (int j = logN - 1; j >= 0; j--) {
    if (h[dp[u][j].first] >= h[v]) {
      max_edge = max(max_edge, dp[u][j].second);
      u = dp[u][j].first;
    }
  }
  if (u == v) return max_edge;
  for (int j = logN - 1; j >= 0; j--) {
    if (dp[u][j].first != dp[v][j].first) {
      max_edge = max(max_edge, max(dp[u][j].second, dp[v][j].second));
      u = dp[u][j].first;
      v = dp[v][j].first;
    }
  }
  max_edge = max(max_edge, max(dp[u][0].second, dp[v][0].second));
  return max_edge;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int m;
  cin >> n >> m;
  vector<edge> edges(m);
  for (int i = 0; i < m; i++) cin >> edges[i].w;
  for (int i = 0; i < m; i++) cin >> edges[i].c;
  for (int i = 0; i < m; i++) {
    cin >> edges[i].u >> edges[i].v;
    edges[i].u--;
    edges[i].v--;
    edges[i].in = i;
  }
  sort(edges.begin(), edges.end(), comp);
  p.resize(n);
  rang.resize(n);
  for (int i = 0; i < n; i++) make_set(i);
  h.resize(n);
  g.resize(n);
  dp.resize(n, vector<pair<int, long long> >(logN));
  long long sum = 0;
  set<pair<int, long long> > min_ost;
  for (int i = 0; i < m; i++) {
    edge e = edges[i];
    int u = e.u, v = e.v;
    if (find_set(u) != find_set(v)) {
      int in = e.in;
      long long w = e.w;
      min_ost.insert({in, w});
      sum += w;
      g[u].push_back({v, w});
      g[v].push_back({u, w});
      union_set(u, v);
    }
  }
  dfs(0, 0, 1);
  preprocess();
  long long s;
  cin >> s;
  long long ans = INF;
  int edge_in = 0;
  for (int i = 0; i < m; i++) {
    edge e = edges[i];
    long long max_edge = max_dissat(e.u, e.v);
    long long val = sum - max_edge + e.w - s / e.c;
    if (val < ans) {
      ans = val;
      edge_in = i;
    }
  }
  edges[edge_in].w -= s / edges[edge_in].c;
  sort(edges.begin(), edges.end(), comp);
  min_ost.clear();
  ans = 0;
  for (int i = 0; i < n; i++) make_set(i);
  for (int i = 0; i < m; i++) {
    edge e = edges[i];
    int u = e.u, v = e.v;
    if (find_set(u) != find_set(v)) {
      int in = e.in;
      long long w = e.w;
      min_ost.insert({in, w});
      ans += w;
      union_set(u, v);
    }
  }
  cout << ans << "\n";
  for (auto i = min_ost.begin(); i != min_ost.end(); i++) {
    pair<int, long long> x = *i;
    cout << x.first + 1 << " " << x.second << "\n";
  }
  return 0;
}