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;
long long n, m;
long long w[200005];
long long c[200005];
long long S;
vector<long long> idxw, idxc;
struct DS {
  long long n;
  long long par[400005];
  long long size[400005];
  void build(long long n) {
    this->n = n;
    for (long long i = 1; i <= n; ++i) {
      par[i] = -1;
      size[i] = 1;
    }
  }
  long long getParent(long long x) {
    if (par[x] == -1) {
      return x;
    }
    par[x] = getParent(par[x]);
    return par[x];
  }
  bool isSameSet(long long x, long long y) {
    return (getParent(x) == getParent(y));
  }
  void setUnion(long long x, long long y) {
    if (isSameSet(x, y)) {
      return;
    }
    long long px = getParent(x);
    long long py = getParent(y);
    if (size[px] < size[py]) {
      par[px] = py;
      size[py] += size[px];
    } else {
      par[py] = px;
      size[px] += size[py];
    }
  }
};
DS ds;
struct Edge {
  long long u;
  long long v;
  long long w;
  long long c;
  Edge(long long u, long long v, long long w, long long c) {
    this->u = u;
    this->v = v;
    this->w = w;
    this->c = c;
  }
};
vector<Edge> edges;
bool cmpw(long long i, long long j) { return (edges[i].w < edges[j].w); }
bool cmpc(long long i, long long j) { return (edges[i].c < edges[j].c); }
vector<long long> nei[200005];
long long logn = 20;
long long mstw = 0;
set<long long> mstedges;
long long p[200005][20];
long long maxidx[200005][20];
long long lev[200005];
long long ans[200005];
void buildMST() {
  long long idx = 0;
  while (mstedges.size() < n - 1) {
    Edge e = edges[idxw[idx++]];
    if (!ds.isSameSet(e.u, e.v)) {
      ds.setUnion(e.u, e.v);
      nei[e.u].push_back(idxw[idx - 1]);
      nei[e.v].push_back(idxw[idx - 1]);
      mstedges.insert(idxw[idx - 1]);
      mstw += e.w;
    }
  }
}
void dfs(long long u) {
  for (long long i = 0; i < nei[u].size(); ++i) {
    long long v;
    if (edges[nei[u][i]].u == u) {
      v = edges[nei[u][i]].v;
    } else {
      v = edges[nei[u][i]].u;
    }
    if (v != p[u][0]) {
      p[v][0] = u;
      lev[v] = lev[u] + 1;
      maxidx[v][0] = nei[u][i];
      dfs(v);
    }
  }
}
void buildp() {
  for (long long i = 1; i < logn; ++i) {
    for (long long u = 1; u <= n; ++u) {
      maxidx[u][i] = maxidx[u][i - 1];
      if (p[u][i - 1] != -1) {
        p[u][i] = p[p[u][i - 1]][i - 1];
        if (edges[maxidx[p[u][i - 1]][i - 1]].w > edges[maxidx[u][i]].w) {
          maxidx[u][i] = maxidx[p[u][i - 1]][i - 1];
        }
      }
    }
  }
}
long long minbw(long long u, long long v) {
  long long V = v;
  long long U = u;
  if (lev[u] < lev[v]) {
    return minbw(v, u);
  }
  long long ret = -1;
  long long diff = lev[u] - lev[v];
  for (long long i = logn - 1; i >= 0; --i) {
    if ((1 << i) & diff) {
      if (ret == -1 || edges[ret].w < edges[maxidx[u][i]].w) {
        ret = maxidx[u][i];
      }
      u = p[u][i];
    }
  }
  if (u == v) {
    return ret;
  }
  for (long long i = logn - 1; i >= 0; --i) {
    if (p[u][i] != p[v][i]) {
      if (ret == -1 || edges[maxidx[u][i]].w > edges[ret].w) {
        ret = maxidx[u][i];
      }
      if (ret == -1 || edges[maxidx[v][i]].w > edges[ret].w) {
        ret = maxidx[v][i];
      }
      u = p[u][i];
      v = p[v][i];
    }
  }
  if (ret == -1 || edges[maxidx[u][0]].w > edges[ret].w) {
    ret = maxidx[u][0];
  }
  if (ret == -1 || edges[maxidx[v][0]].w > edges[ret].w) {
    ret = maxidx[v][0];
  }
  return ret;
}
long long getnewmstw(long long idx) {
  Edge e = edges[idx];
  long long minwidx = minbw(e.u, e.v);
  return mstw - edges[minwidx].w + e.w;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  ds.build(n);
  logn = log2(n) + 1;
  for (long long i = 0; i < m; ++i) {
    cin >> w[i];
  }
  for (long long i = 0; i < m; ++i) {
    cin >> c[i];
  }
  for (long long i = 0; i < m; ++i) {
    long long a, b;
    cin >> a >> b;
    edges.push_back(Edge(a, b, w[i], c[i]));
    idxw.push_back(i);
    idxc.push_back(i);
  }
  sort(idxw.begin(), idxw.end(), cmpw);
  sort(idxc.begin(), idxc.end(), cmpc);
  cin >> S;
  for (long long i = 0; i < 200005; ++i) {
    for (long long j = 0; j < 20; ++j) {
      p[i][j] = -1;
      maxidx[i][j] = -1;
    }
  }
  buildMST();
  lev[1] = 0;
  dfs(1);
  buildp();
  for (long long i = 0; i < idxc.size(); ++i) {
    long long idx = idxc[i];
    if (mstedges.find(idx) != mstedges.end()) {
      ans[idx] = mstw - S / c[idx];
    } else {
      ans[idx] = getnewmstw(idx) - S / c[idx];
    }
  }
  long long mindx = 0;
  for (long long i = 0; i < m; ++i) {
    if (ans[i] < ans[mindx]) {
      mindx = i;
    }
  }
  cout << ans[mindx] << endl;
  if (mstedges.find(mindx) != mstedges.end()) {
    for (set<long long>::iterator it = mstedges.begin(); it != mstedges.end();
         ++it) {
      if (*it == mindx) {
        cout << *it + 1 << " " << edges[*it].w - S / c[*it] << endl;
      } else {
        cout << *it + 1 << " " << edges[*it].w << endl;
      }
    }
  } else {
    Edge e = edges[mindx];
    long long remidx = minbw(e.u, e.v);
    for (set<long long>::iterator it = mstedges.begin(); it != mstedges.end();
         ++it) {
      if (*it != remidx) {
        cout << *it + 1 << " " << edges[*it].w << endl;
      }
    }
    cout << mindx + 1 << " " << edges[mindx].w - S / c[mindx] << endl;
  }
}