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;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
string to_string(const vector<bool>& v) {
  bool first = true;
  string res = "{";
  for (auto&& i : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(i);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res;
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " +
         to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
const int mxn = 2e5 + 19, K = 25;
int n, m;
long long s;
long long c[mxn];
long long w[mxn];
int vis[mxn];
int lca[mxn][K];
int minLca[mxn][K];
int dep[mxn];
int us[mxn];
int topEdge[mxn];
pair<int, int> edges[mxn];
vector<pair<int, int> > graph[mxn];
long long getMin(int a, int b) {
  int ans = 1e9;
  if (dep[a] < dep[b]) {
    swap(a, b);
  }
  for (int l = K - 1; l >= 0; l--) {
    if (dep[a] - (1 << l) >= dep[b]) {
      ans = min(ans, minLca[a][l]);
      a = lca[a][l];
    }
  }
  if (a == b) {
    return ans;
  }
  for (int l = K - 1; l >= 0; l--) {
    if (lca[a][l] != lca[b][l]) {
      ans = min(ans, minLca[a][l]);
      ans = min(ans, minLca[b][l]);
      a = lca[a][l];
      b = lca[b][l];
    }
  }
  ans = min(ans, minLca[a][0]);
  ans = min(ans, minLca[b][0]);
  return ans;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> w[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    graph[a].emplace_back(b, i);
    graph[b].emplace_back(a, i);
    edges[i] = {a, b};
  }
  cin >> s;
  priority_queue<pair<int, pair<int, int> > > pq;
  pq.push({0, {1, -1}});
  vector<int> used;
  while (!pq.empty()) {
    auto au = pq.top();
    pq.pop();
    int x = au.second.first;
    int edge = au.second.second;
    if (vis[x]) {
      continue;
    }
    vis[x] = 1;
    if (edge == -1) {
      dep[x] = 1;
    } else {
      topEdge[x] = edge;
      us[edge] = 1;
      used.push_back(edge);
      lca[x][0] = x ^ edges[edge].first ^ edges[edge].second;
      minLca[x][0] = -w[edge];
      dep[x] = dep[lca[x][0]] + 1;
      for (int i = 1; i < K; i++) {
        lca[x][i] = lca[lca[x][i - 1]][i - 1];
        minLca[x][i] = min(minLca[x][i - 1], minLca[lca[x][i - 1]][i - 1]);
      }
    }
    for (auto pr : graph[x]) {
      int next = pr.first;
      int weight = w[pr.second];
      pq.push({-weight, {next, pr.second}});
    }
  }
  long long total = 0;
  for (int x : used) {
    total += w[x];
  }
  long long best = total + 1;
  long long which = -1;
  for (int i = 0; i < m; i++) {
    long long here;
    if (us[i]) {
      here = total - (s / c[i]);
    } else {
      long long hereBase =
          total + w[i] + getMin(edges[i].first, edges[i].second);
      here = hereBase - (s / c[i]);
    }
    if (here < best) {
      best = here;
      which = i;
    }
  }
  cout << best << "\n";
  long long save = s / c[which];
  if (us[which]) {
    for (int e : used) {
      if (e == which) {
        cout << e + 1 << " " << w[e] - save << "\n";
      } else {
        cout << e + 1 << " " << w[e] << "\n";
      }
    }
  } else {
    int a = edges[which].first;
    int b = edges[which].second;
    if (dep[a] < dep[b]) {
      swap(a, b);
    }
    int mn = 1e9;
    int th = -1;
    while (dep[a] > dep[b]) {
      if (-w[topEdge[a]] < mn) {
        mn = -w[topEdge[a]];
        th = topEdge[a];
      }
      a = lca[a][0];
    }
    while (a != b) {
      if (-w[topEdge[a]] < mn) {
        mn = -w[topEdge[a]];
        th = topEdge[a];
      }
      a = lca[a][0];
      if (-w[topEdge[b]] < mn) {
        mn = -w[topEdge[b]];
        th = topEdge[b];
      }
      b = lca[b][0];
    }
    cout << which + 1 << " " << w[which] - save << "\n";
    for (int x : used) {
      if (x == th) {
        continue;
      }
      cout << x + 1 << " " << w[x] << "\n";
    }
  }
}