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 double Pi = acos((double)-1);
const long long oo((long long)1e+9);
template <typename T>
inline ostream &operator<<(ostream &out, const vector<T> &v) {
  for (auto &it : v) out << it << ' ';
  return out;
}
template <typename T>
inline istream &operator>>(istream &in, vector<T> &v) {
  for (auto &it : v) in >> it;
  return in;
}
template <typename T1, typename T2>
inline ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << p.first << ' ' << p.second << ' ';
  return out;
}
template <typename T1, typename T2>
inline istream &operator>>(istream &in, pair<T1, T2> &p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T>
inline ostream &operator<<(ostream &out, const set<T> &p) {
  for (auto &i : p) out << i << ' ';
  return out;
}
template <typename T>
inline istream &operator>(istream &in, T &p) {
  return in >> p;
}
template <typename T>
inline ostream &operator<(ostream &out, const T &p) {
  return out << p;
}
template <typename T1, typename T2>
inline pair<T1 &, T2 &> unzip_pair(T1 &p1, T2 &p2) {
  return pair<T1 &, T2 &>(p1, p2);
}
template <typename T>
inline T min(const vector<T> &p) {
  T ans = p[0];
  for (auto &i : p) ans = min(ans, i);
  return ans;
}
template <typename T>
inline T max(const vector<T> &p) {
  T ans = p[0];
  for (auto &i : p) ans = max(ans, i);
  return ans;
}
int n, m;
vector<long long> w, c;
vector<vector<pair<int, int>>> nx;
long long s, cur = 0;
bool cmp(const pair<pair<int, int>, int> p1,
         const pair<pair<int, int>, int> p2) {
  return w[p1.second] < w[p2.second];
}
int snm[200200];
int getX(int a) {
  if (snm[a] != a) snm[a] = getX(snm[a]);
  return snm[a];
}
void merge(int a, int b) {
  a = getX(a);
  b = getX(b);
  snm[a] = b;
}
vector<vector<int>> lca, ans;
long long tin[200200], tout[200200];
bool isA(int a, int b) { return tin[a] <= tin[b] && tout[a] >= tout[b]; }
long long build(int v, int reserved_1, int cr, long long t) {
  tin[v] = t;
  if (reserved_1 != -1) {
    lca[v].push_back(reserved_1);
    ans[v].push_back(cr);
    int last = reserved_1;
    while (lca[last].size() >= lca[v].size()) {
      int h = lca[v].size() - 1;
      ans[v].push_back(ans[v].back());
      if (w[ans[v][h + 1]] < w[ans[lca[v][h]][h]]) {
        ans[v][h + 1] = ans[lca[v][h]][h];
      }
      lca[v].push_back(lca[last][h]);
      last = lca[v].back();
    }
  }
  for (auto i : nx[v]) {
    if (i.first == reserved_1) continue;
    t = build(i.first, v, i.second, t + 1);
  }
  tout[v] = t;
  return t + 1;
}
int getH(int a, int b) {
  int cur = -1;
  int p = lca[b].size();
  while (!isA(b, a)) {
    p = min(p, (int)lca[b].size());
    p = max(0, p - 1);
    while (p > 0 && isA(lca[b][p], a)) p--;
    if (cur == -1 || w[cur] < w[ans[b][p]]) {
      cur = ans[b][p];
    }
    b = lca[b][p];
  }
  return cur;
}
void setAns(int v, int reserved_1, int bl) {
  for (auto i : nx[v]) {
    if (i.first == reserved_1) continue;
    if (i.second != bl) cout < i.second + 1 < ' ' < w[i.second] < '\n';
    setAns(i.first, v, bl);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout < fixed < setprecision(7);
  for (int i = 0; i < 200200; i++) snm[i] = i;
  cin > n > m;
  (w).resize(m);
  (c).resize(m);
  (nx).resize(n);
  (lca).resize(n);
  (ans).resize(n);
  cin > w > c;
  vector<pair<pair<int, int>, int>> ms;
  for (int i = 0; i < (m); i++) {
    int a, b;
    cin > a > b;
    a--;
    b--;
    ms.push_back({{a, b}, i});
  }
  sort((ms).begin(), (ms).end(), cmp);
  cin > s;
  for (int i = 0; i < (m); i++) {
    if (getX(ms[i].first.first) != getX(ms[i].first.second)) {
      merge(ms[i].first.first, ms[i].first.second);
      nx[ms[i].first.first].push_back({ms[i].first.second, ms[i].second});
      nx[ms[i].first.second].push_back({ms[i].first.first, ms[i].second});
      cur += w[ms[i].second];
    }
  }
  build(0, -1, -1, 0);
  long long cur_ans = 1e+18, bl = -1, an = -1;
  for (int i = 0; i < (m); i++) {
    long long ca = cur + w[ms[i].second] - s / c[ms[i].second];
    int p1 = getH(ms[i].first.first, ms[i].first.second);
    int p2 = getH(ms[i].first.second, ms[i].first.first);
    if (p1 == -1) p1 = p2;
    if (p2 != -1 && w[p1] < w[p2]) p1 = p2;
    ca -= w[p1];
    if (cur_ans > ca) {
      cur_ans = ca;
      bl = p1;
      an = ms[i].second;
    }
  }
  cout < cur_ans < '\n';
  cout < an + 1 < ' ' < w[an] - s / c[an] < '\n';
  setAns(0, -1, bl);
  return 0;
}