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 mult(int x, int y) {
  long long int ans, x1 = (long long int)x, y1 = (long long int)y;
  ans = (x1 * y1) % 1000000007;
  return (int)ans;
}
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int lcm(int a, int b) { return a * (b / gcd(a, b)); }
long long int pow1(long long int a, long long int b) {
  long long int ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % 1000000007;
    a = (a * a) % 1000000007;
    b >>= 1;
  }
  return ans;
}
int mina(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] < x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
int maxa(int arr[], int n) {
  int x = arr[0], i, pos = 0;
  for (i = 1; i < n; i++) {
    if (arr[i] > x) {
      x = arr[i];
      pos = i;
    }
  }
  return x;
}
vector<vector<int> > v, indexa, costs;
int base[200005], ptr;
int chainno, chainind[200005], chainhead[200005], posinbase[200005];
int depth[200005], p[22][200005], otherend[200005], child[200005];
pair<int, int> st[200005 * 6];
int revmap[200005];
vector<pair<int, int> > e;
int w[200005], c[200005];
int endpt1[200005], endpt2[200005];
void build(int low, int high, int pos) {
  if (low == high) {
    st[pos] = make_pair(base[low], revmap[low]);
    return;
  }
  int mid = (low + high) >> 1;
  build(low, mid, 2 * pos);
  build(mid + 1, high, 2 * pos + 1);
  int lft = st[2 * pos].first, rht = st[2 * pos + 1].first;
  if (lft >= rht)
    st[pos] = st[2 * pos];
  else
    st[pos] = st[2 * pos + 1];
}
pair<int, int> rmq(int low, int high, int l, int r, int pos) {
  if (high < l || low > r) return make_pair(-INT_MAX, -1);
  if (l <= low && r >= high) return st[pos];
  int mid = (low + high) >> 1;
  pair<int, int> lft = rmq(low, mid, l, r, 2 * pos),
                 rht = rmq(mid + 1, high, l, r, 2 * pos + 1);
  if (lft.first >= rht.first)
    return lft;
  else
    return rht;
}
pair<int, int> query_up(int u1, int v1) {
  int uchain, vchain = chainind[v1], ind;
  pair<int, int> ans = make_pair(-INT_MAX, -1);
  while (true) {
    uchain = chainind[u1];
    if (uchain == vchain) {
      if (u1 == v1) break;
      pair<int, int> quer =
          rmq(1, ptr - 1, posinbase[v1] + 1, posinbase[u1], 1);
      ans = max(ans, quer);
      break;
    }
    ans = max(ans,
              rmq(1, ptr - 1, posinbase[chainhead[uchain]], posinbase[u1], 1));
    u1 = chainhead[uchain];
    u1 = p[0][u1];
  }
  return ans;
}
int lca(int u1, int v1) {
  if (depth[u1] < depth[v1]) swap(u1, v1);
  int diff = depth[u1] - depth[v1], i, j;
  for (i = 0; i < 22; i++)
    if ((diff >> i) & 1) u1 = p[i][u1];
  if (u1 == v1) return u1;
  for (i = 22 - 1; i >= 0; i--)
    if (p[i][u1] != p[i][v1]) {
      u1 = p[i][u1];
      v1 = p[i][v1];
    }
  return p[0][u1];
}
pair<int, int> query(int u1, int v1) {
  int comm = lca(u1, v1);
  return max(query_up(u1, comm), query_up(v1, comm));
}
map<pair<int, int>, int> m1;
void hld(int curnode, int cost, int n, int indx) {
  if (chainhead[chainno] == -1) chainhead[chainno] = curnode;
  chainind[curnode] = chainno;
  posinbase[curnode] = ptr;
  revmap[ptr] = indx;
  base[ptr++] = cost;
  int mxchild = -1, ncost = 0, i, j, cnt = 0, pos1;
  for (vector<int>::iterator itr = v[curnode].begin(); itr != v[curnode].end();
       itr++) {
    int v1 = *itr;
    if (v1 != p[0][curnode]) {
      if (mxchild == -1 || child[mxchild] < child[v1])
        mxchild = v1, ncost = costs[curnode][cnt];
    }
    cnt++;
  }
  cnt = 0;
  if (mxchild != -1) hld(mxchild, ncost, n, m1[make_pair(curnode, mxchild)]);
  for (vector<int>::iterator itr = v[curnode].begin(); itr != v[curnode].end();
       itr++) {
    int v1 = *itr;
    if (v1 != p[0][curnode] && v1 != mxchild) {
      chainno++;
      hld(v1, costs[curnode][cnt], n, m1[make_pair(curnode, v1)]);
    }
    cnt++;
  }
}
void dfs(int u, int par) {
  if (u == 1)
    depth[u] = 0;
  else
    depth[u] = depth[par] + 1;
  p[0][u] = par;
  child[u] = 1;
  int cnt = 0;
  for (vector<int>::iterator itr = v[u].begin(); itr != v[u].end(); itr++) {
    int v1 = *itr;
    if (v1 != par) {
      otherend[indexa[u][cnt]] = v1;
      dfs(v1, u);
      child[u] += child[v1];
    }
    cnt++;
  }
}
int arr1[200005], arr2[200005];
bool mark[200005];
int finda(int i) {
  if (arr1[i] == i)
    return i;
  else
    return arr1[i] = finda(arr1[i]);
}
void makeunion(int a, int b) {
  int a1 = finda(a);
  int a2 = finda(b);
  if (arr2[a1] < arr2[a2])
    arr1[a1] = a2;
  else if (arr2[a2] < arr2[a1])
    arr1[a2] = a1;
  else {
    arr2[a1]++;
    arr1[a2] = a1;
  }
}
int main() {
  int x, y, n, m, i, j, k;
  long long int tot;
  scanf("%d", &n);
  scanf("%d", &m);
  for (i = 1; i < m + 1; i++) scanf("%d", &w[i]);
  for (i = 1; i < m + 1; i++) scanf("%d", &c[i]);
  for (i = 1; i < m + 1; i++) {
    scanf("%d", &x);
    scanf("%d", &y);
    endpt1[i] = x;
    endpt2[i] = y;
    e.push_back(make_pair(w[i], i));
  }
  scanf("%lld", &tot);
  sort(e.begin(), e.end());
  for (i = 1; i < n + 1; i++) {
    arr1[i] = i;
    arr2[i] = 1;
  }
  long long int cost = 0;
  v.resize(n + 2);
  costs.resize(n + 2);
  indexa.resize(n + 2);
  for (i = 0; i < n + 2; i++) {
    chainhead[i] = -1;
    for (j = 0; j < 22; j++) p[j][i] = -1;
  }
  int cn = 0;
  vector<int> final;
  for (i = 0; i < m; i++) {
    pair<int, int> front = e[i];
    int u1 = endpt1[front.second], v1 = endpt2[front.second];
    int a = finda(u1);
    int b = finda(v1);
    if (a != b) {
      final.push_back(front.second);
      v[u1].push_back(v1);
      v[v1].push_back(u1);
      m1[make_pair(u1, v1)] = front.second;
      m1[make_pair(v1, u1)] = front.second;
      costs[u1].push_back(front.first);
      costs[v1].push_back(front.first);
      indexa[u1].push_back(cn);
      indexa[v1].push_back(cn++);
      mark[front.second] = true;
      cost += front.first;
      makeunion(endpt1[front.second], endpt2[front.second]);
    }
  }
  dfs(1, -1);
  ptr = 1;
  chainno = 0;
  hld(1, -INT_MAX, n, 0);
  build(1, ptr - 1, 1);
  for (i = 1; i < 22; i++)
    for (j = 0; j < n + 1; j++)
      if (p[i - 1][j] != -1) p[i][j] = p[i - 1][p[i - 1][j]];
  long long int ans = LLONG_MAX;
  pair<int, int> indx = make_pair(-INT_MAX, -INT_MAX);
  for (i = 1; i < m + 1; i++) {
    if (mark[i]) {
      if (cost - (tot / (long long int)c[i]) < ans)
        indx = make_pair(-INT_MAX, i);
      ans = min(ans, cost - (tot / (long long int)c[i]));
      continue;
    }
    int u1 = endpt1[i], v1 = endpt2[i];
    pair<int, int> pra = query(u1, v1);
    long long int cost1 = (long long int)pra.first;
    int ind = pra.second;
    if (w[i] - (int)(tot / c[i]) < (int)cost1) {
      if (cost - cost1 + (long long int)w[i] - (tot / c[i]) < ans)
        indx = make_pair(i, ind);
      ans = min(ans, cost - cost1 + (long long int)w[i] - (tot / c[i]));
    }
  }
  printf("%lld\n", ans);
  if (indx.first == -INT_MAX) {
    for (i = 0; i < final.size(); i++) {
      if (final[i] != indx.second)
        printf("%d %d\n", final[i], w[final[i]]);
      else
        printf("%d %d\n", final[i], w[final[i]] - (int)(tot / c[final[i]]));
    }
  } else {
    for (i = 0; i < final.size(); i++) {
      if (final[i] != indx.second)
        printf("%d %d\n", final[i], w[final[i]]);
      else
        printf("%d %d\n", indx.first,
               w[indx.first] - (int)(tot / c[indx.first]));
    }
  }
  return 0;
}