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:
import java.io.*;
import java.util.*;

public class CF733F
{
	static final boolean _DEBUG = true;

	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner(BufferedReader _br) {
			br = _br;
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					e.printStackTrace();
					return "";
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

	static MyScanner   scan;
	static PrintWriter out;

	static int debugCount = 0;
	static void debug(String msg) {
		if (_DEBUG && debugCount < 200) {
			out.println(msg);
			out.flush();
			debugCount++;
		}
	}
	
    public static void main (String args[]) throws IOException {
//    	scan = new MyScanner(new BufferedReader(new FileReader("test.in")));
    	scan = new MyScanner(new BufferedReader(new InputStreamReader(System.in)));
    	out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        CF733F inst = new CF733F();
        inst.execute();
        out.close();
    }
    
	class DisjointSet {
		int[] parent;
		int[] sizes;
		
		public DisjointSet(int _size) {
			parent = new int[_size];
			sizes = new int[_size];
			for (int i = 0; i < _size; i++) {
				parent[i] = i;
				sizes[i] = 1;
			}
		}
		
		int find(int x) {
			if (parent[x] == x) return x;
			parent[x] = find(parent[x]);
			return parent[x];
		}
		
		int size(int x) {
			return sizes[find(x)];
		}
		
		boolean union(int x, int y) {
			int rx = find(x);
			int ry = find(y);
			if (rx != ry) {
				if (sizes[rx] < sizes[ry]) {
					int temp = rx;
					rx = ry;
					ry = temp;
				}
				parent[ry] = rx;
				sizes[rx] += sizes[ry];
				return true;
			} else {
				return false;
			}
		}
		
	}

	class Node {
    	int id;
    	LinkedList<Edge> nbs = new LinkedList<Edge>();
    	Node (int _id) {
    		id = _id;
    	}
    	Node getOther(Edge edge) {
    		return edge.a == this ? edge.b : edge.a;
    	}
    	
    	void dfs (Edge e, Node parent, int ht) {
    		tin = timer++;
    		up[0] = parent;
    		maxD[0] = e;
    		height = ht;
    		for (int i = 1; i < l; i++) {
    			up[i] = up[i-1].up[i-1];
    			maxD[i] = maxD[i-1].larger(up[i-1].maxD[i-1]);
    		}
    		for (Edge edge : nbs) {
    			if (edge.used) {
    				Node other = getOther(edge);
    				if (other != parent) {
    					other.dfs(edge, this, ht+1);
    				}
    			}
    		}
    		tout = timer++;
    	}
    	
    	boolean isAncestor(Node other) {
    		return tin <= other.tin && tout >= other.tout;
    	}
    	
    	int tin;
    	int tout;
    	int height;
    	Node[] up   = new Node[l];
    	Edge[] maxD = new Edge[l];
    }
    
    int l = 0;
    int timer = 0;
    
	Node lca(Node u, Node v) {
		if (u.isAncestor(v)) return u;
		if (v.isAncestor(u)) return v;
		
		Node cur = u;
		for (int i = l-1; i >= 0; i--) {
			if (!cur.up[i].isAncestor(v)) {
				cur = cur.up[i];
			}
		}
		return cur.up[0];
	}
	
	Edge maxD(Node u, Node v) {
		if (u.height > v.height) {
			Node tmp = u;
			u = v;
			v = tmp;
		}
		Node lca = null;
		Node cur;
		Edge res = empty;
		if (u.isAncestor(v)) {
			lca = u;
		} else {
			cur = u;
			for (int i = l-1; i >= 0; i--) {
				if (!cur.up[i].isAncestor(v)) {
					res = res.larger(cur.maxD[i]);
					cur = cur.up[i];
				}
			}
			lca = cur.up[0];
			res = res.larger(cur.maxD[0]);
		}
		cur = v;
		for (int i = l-1; i >= 0; i--) {
			if (!cur.up[i].isAncestor(lca)) {
				res = res.larger(cur.maxD[i]);
				cur = cur.up[i];
			}
		}
		res = res.larger(cur.maxD[0]);
		
		return res;
	}
	
	Edge empty = new Edge(0);
	
    class Edge implements Comparable<Edge>{
    	int id;
    	Node a, b;
    	int w;
    	int c;
    	
    	Edge(int _id) {
    		id = _id;
    	}
    	
    	boolean used = false;
		@Override
		public int compareTo(Edge o) {
			return w - o.w;
		}
		
		Edge larger(Edge o) {
			return w >= o.w ? this : o;
		}
    }
    
    void execute() throws IOException {
        Node[] nodes;
        Edge[] edges;

        int n = scan.nextInt();
    	int m = scan.nextInt();
    	l = (int)Math.ceil(Math.log(n)/Math.log(2)) + 1;
    	
    	nodes = new Node[n];
    	for (int i = 0; i < n; i++) {
    		nodes[i] = new Node(i);
    	}
    	edges = new Edge[m];
    	for (int i = 0; i < m; i++) {
    		edges[i] = new Edge(i+1);
    		edges[i].w = scan.nextInt();
    	}
    	for (int i = 0; i < m; i++) {
    		edges[i].c = scan.nextInt();
    	}
    	for (int i = 0; i < m; i++) {
    		Node a = nodes[scan.nextInt() - 1];
    		Node b = nodes[scan.nextInt() - 1];
    		edges[i].a = a;
    		edges[i].b = b;
    		a.nbs.add(edges[i]);
    		b.nbs.add(edges[i]);
    	}
    	Arrays.sort(edges);
    	
    	int S = scan.nextInt();
    	
    	long total = 0;
    	
    	DisjointSet ds = new DisjointSet(n);
    	int count = 0;
    	Edge[] mst = new Edge[n-1];
    	for (Edge edge : edges) {
    		if (ds.union(edge.a.id, edge.b.id) ) {
    			edge.used = true;
    			total += edge.w;
    			mst[count] = edge;
    			
    			count++;
    			if (count >= n-1) {
    				break;
    			}
    		}
    	}
    	
    	Node root = nodes[0];
    	root.dfs(empty, root, 0);
    	
    	
    	int maxSave = -1;
    	Edge excluded = null;
    	Edge modified = null;
    	for (Edge edge : edges) {
    		int save;
    		if (edge.used) {
    			save = S/edge.c;
    			if (save > maxSave) {
    				maxSave = save;
    				excluded = edge;
    				modified = edge;
    			}
    		} else {
    			Edge replace = maxD(edge.a, edge.b);
    			save = S/edge.c + replace.w - edge.w;
    			if (save > maxSave) {
    				maxSave = save;
    				excluded = replace;
    				modified = edge;
    			}
    		}
    	}
    	
//    	debug(total + " " + count);
   	
    	out.println(total - maxSave);
    	for (Edge edge : mst) {
    		if (edge != excluded) {
    			out.println(edge.id + " " + edge.w);
    		}
    	}
    	out.println(modified.id + " " + (modified.w - S/modified.c));
    }
}