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 JAVA):

Solution:
//package que_a;

import java.io.*;
import java.util.*;
import java.math.*;

public class utkarsh {

    InputStream is;
    PrintWriter out;
    
    long mod = (long) (1e9 + 7), inf = (long) (3e18);
    
    class edge {
        int U, V, W, C, I;
        edge(int w, int i) {
            W = w;
            I = i;
        }
    }
    
    class pair {
        int V, W, I;
        pair(int v, int w, int i) {
            V = v;  W = w;  I = i;
        }
    }
    
    int pt[];
    ArrayList <pair> a[];
    
    int root(int x) {
        while(x != pt[x]) {
            pt[x] = pt[pt[x]];
            x = pt[x];
        }   return x;
    }
    
    boolean union(int u, int v) {
        int ru = root(u);
        int rv = root(v);
        if(ru == rv)    return false;
        pt[ru] = rv;    return true;
    }
    
    int level[], dp[][], N = 18;
    pair wt[][];
    
    void dfs(int s, int pt) {
        dp[s][0] = pt;
        for(pair p : a[s]) {
            if(p.V == pt)   continue;
            level[p.V] = level[s] + 1;
            wt[p.V][0] = new pair(0, p.W, p.I);
            dfs(p.V, s);
        }
    }
    
    pair getWt(int u, int v) {
        if(level[u] > level[v]) {
            u ^= v; v ^= u; u ^= v;
        }
        int d = level[v] - level[u];
        pair p = new pair(0, 0, -1);
        for(int i = 0; i < N; i++) {
            if(((d >> i) & 1) == 1) {
                if(wt[v][i].W > p.W) p = wt[v][i];
                v = dp[v][i];
            }
        }
        if(u == v)  return p;
        for(int i = N-1; i >= 0; i--) {
            if(dp[u][i] != dp[v][i]) {
                if(wt[u][i].W > p.W)    p = wt[u][i];
                if(wt[v][i].W > p.W)    p = wt[v][i];
                u = dp[u][i];   v = dp[v][i];
            }
        }
        if(wt[u][0].W > p.W)    p = wt[u][0];
        if(wt[v][0].W > p.W)    p = wt[v][0];
        return p;
    }
    
    void solve() {
        int n = ni(), m = ni();
        edge e[] = new edge[m];
        for(int i = 0; i < m; i++)  e[i] = new edge( ni(), i );
        for(int i = 0; i < m; i++)  e[i].C = ni();
        for(int i = 0; i < m; i++) {
            e[i].U = ni() - 1;
            e[i].V = ni() - 1;
        }
        int S = ni();
        boolean vst[] = new boolean[m];
        long T = 0;
        
        // Kruskal
        Arrays.sort(e, (edge u, edge v) -> (u.W - v.W));
        pt = new int[n];
        a = new ArrayList[n];
        for(int i = 0; i < n; i++) {
            pt[i] = i;
            a[i] = new ArrayList<>();
        }
        for(int i = 0; i < m; i++) {
            int u = e[i].U, v = e[i].V;
            if(union(u, v)) {
                T += e[i].W;
                vst[e[i].I] = true;
                a[u].add(new pair(v, e[i].W, e[i].I));
                a[v].add(new pair(u, e[i].W, e[i].I));
            }
        }
        
        //LCA
        level = new int[n];
        dp = new int[n][N];
        wt = new pair[n][N];    wt[0][0] = new pair(0, 0, -1);
        dfs(0, -1);
        for(int j = 1; j < N; j++) {
            for(int i = 0; i < n; i++) {
                if(dp[i][j-1] == -1) {
                    dp[i][j] = -1;
                    wt[i][j] = wt[0][0];
                } else {
                    dp[i][j] = dp[ dp[i][j-1] ][j-1];
                    pair p1 = wt[ dp[i][j-1] ][j-1];
                    pair p2 = wt[i][j-1];
                    if(p1.W > p2.W) {
                        wt[i][j] = p1;
                    } else {
                        wt[i][j] = p2;
                    }
                }
            }
        }
        
        //sol
        int D = 0, I = -1, J = -1;
        for(int i = 0; i < m; i++) {
            int u = e[i].U, v = e[i].V;
            pair wt = getWt(u, v);
            int d = e[i].W - wt.W - S / e[i].C;
            if(d < D) {
                D = d;  I = e[i].I;  J = wt.I;
            }
        }
        out.println(T + D);
        for(int i = 0; i < m; i++) {
            int j = e[i].I;
            if(j == I) {
                out.println((j+1) +" "+ (e[i].W - S / e[i].C));
            } else if(vst[j] && j != J) {
                out.println((j+1) +" "+ e[i].W);
            }
        }
    }
    
    long mp(long b, long e) {
        long r = 1;
        while(e > 0) {
            if((e&1) == 1)  r = (r * b) % mod;
            b = (b * b) % mod;
            e >>= 1;
        }
        return r;
    }

    //---------- I/O Template ----------
    
    public static void main(String[] args) { new utkarsh().run(); }
    void run() { 
        is = System.in;
        out = new PrintWriter(System.out);
        solve();
        out.flush();
    }
    
    byte input[] = new byte[1024];
    int len = 0, ptr = 0;
    
    int readByte() { 
        if(ptr >= len) { ptr = 0; 
            try { len = is.read(input); } 
            catch(IOException e) { throw new InputMismatchException(); } 
            if(len <= 0) { return -1; } 
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() { 
        int b = readByte(); 
        while(b != -1 && isSpaceChar(b)) { b = readByte(); } 
        return b;
    }
    
    char nc() { return (char)skip(); }
    String ns() { 
        int b = skip(); 
        StringBuilder sb = new StringBuilder(); 
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); } 
        return sb.toString();
    }
    String nLine() { 
        int b = skip(); 
        StringBuilder sb = new StringBuilder(); 
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); } 
        return sb.toString();
    }
    int ni() { 
        int n = 0, b = readByte(); 
        boolean minus = false; 
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); } 
        if(b == '-') { minus = true; b = readByte(); } 
        if(b == -1) { return -1; }  //no input 
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); } 
        return minus ? -n : n;
    }
    long nl() { 
        long n = 0L;    int b = readByte(); 
        boolean minus = false; 
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); } 
        if(b == '-') { minus = true; b = readByte(); } 
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); } 
        return minus ? -n : n;
    }

    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) { 
        int a[] = new int[n]; 
        for(int i = 0; i < n; i++) { a[i] = ni(); } 
        return a;
    }
    char[] ns(int n) { 
        char c[] = new char[n]; 
        int i, b = skip(); 
        for(i = 0; i < n; i++) { 
            if(isSpaceChar(b)) { break; } 
            c[i] = (char)b; b = readByte(); 
        } return i == n ? c : Arrays.copyOf(c,i);
    }
}