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 Main
{
	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)));
        Main inst = new Main();
        inst.execute();
        out.close();
    }
    
    private static 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;
			}
		}			
	}
    
    private static class Node {
    	int id;
    	LinkedList<Edge> connected;
    	
    	public Node(int id) {
    		this.id = id;
    		connected = new LinkedList<Edge>();
    	}
    }
    
    private static class Edge implements Comparable<Edge> {
    	int id;
    	Node node1;
    	Node node2;
    	int weight;
    	int cost;
    	
    	public Edge(int id) {
    		this.id = id;
    		node1 = node2 = null;
    		cost = weight = Integer.MAX_VALUE;
    	}
    	
		public int compareTo(Edge o) {
			return this.weight - o.weight;
		}
    }
    
    private static int N;
    private static int M;
    private static int log;
    private static int timer;
    private static Node[] nodes;
    private static Edge[] edges;
    private static int[] tins;
    private static int[] touts;
    private static int[] heights;
    private static Node[][] ups;
    private static Edge[][] maxEdges;
    private static boolean[] used;
    
    private static Edge getMaxEdge(Edge edge1, Edge edge2) {
    	if (edge1 != null && (edge2 == null || edge1.weight > edge2.weight)) {
    		return edge1;
    	} else {
    		return edge2;
    	}
    }
    
    private static void dfs(Node node, Node parent, Edge edge) {
    	tins[node.id] = timer++;
    	ups[node.id][0] = parent;
    	maxEdges[node.id][0] = edge;
    	heights[node.id] = heights[parent.id]+1;
//    	out.println("dfs node "+(node.id+1)+" parent "+(parent.id+1));
    	for (int i = 1; i < log; i++) {
			Node prev = ups[node.id][i-1];
    		ups[node.id][i] = ups[prev.id][i-1];
    		maxEdges[node.id][i] = getMaxEdge(maxEdges[node.id][i-1], maxEdges[prev.id][i-1]);
    	}
    	for (Edge tarEdge : node.connected) {
    		if (used[tarEdge.id]) {
    			Node target = null;
        		if (tarEdge.node1 == node) {
        			target = tarEdge.node2;
        		} else {
        			target = tarEdge.node1;
        		}
    			if (target != parent) {
    				dfs(target, node, tarEdge);
    			}
    		}
    	}
    	touts[node.id] = timer++;
    }
    
    private static boolean isAnOf(Node an, Node ch) {
    	return tins[an.id] <= tins[ch.id] && touts[an.id] >= touts[ch.id];
    }
    
    private static Edge maxEdge(Node node1, Node node2) {
    	if (heights[node2.id] < heights[node1.id]) {
    		Node temp = node2;
    		node2 = node1;
    		node1 = temp;
    	}
    	Node lca = null;
    	Node curNode = null;
    	Edge maxEdge = null;
    	if (isAnOf(node1, node2)) {
    		lca = node1;
    	} else {
    		curNode = node1;
    		for (int i = log-1; i >= 0; i--) {
    			if (!isAnOf(ups[curNode.id][i], node2)) {
//    				out.println("ans " + (node2.id+1) + " " + (ups[curNode.id][i].id+1));
    				maxEdge = getMaxEdge(maxEdge, maxEdges[curNode.id][i]);
    				curNode = ups[curNode.id][i];
    			}
    		}
    		lca = ups[curNode.id][0];
			maxEdge = getMaxEdge(maxEdge, maxEdges[curNode.id][0]);
    	}
    	curNode = node2;
		for (int i = log-1; i >= 0; i--) {
			if (!isAnOf(ups[curNode.id][i], lca)) {
				maxEdge = getMaxEdge(maxEdge, maxEdges[curNode.id][i]);
				curNode = ups[curNode.id][i];
			}
		}
		maxEdge = getMaxEdge(maxEdge, maxEdges[curNode.id][0]);
//		out.println((node1.id+1)+" "+(node2.id+1)+" "+(lca.id+1));
    	return maxEdge;
    }
    
    private void execute() throws IOException {
    	N = scan.nextInt();
    	M = scan.nextInt();
    	log = (int)Math.ceil(Math.log(N) / Math.log(2))+1;
    	timer = 0;
    	nodes = new Node[N];
    	edges = new Edge[M];
    	tins = new int[N];
    	touts = new int[N];
    	heights = new int[N];
    	ups = new Node[N][log];
    	maxEdges = new Edge[N][log];
    	used = new boolean[M];
    	for (int i = 0; i < N; i++) {
    		nodes[i] = new Node(i);
    	}
    	for (int i = 0; i < M; i++) {
    		edges[i] = new Edge(i);
    		edges[i].weight = scan.nextInt();
    	}
    	for (int i = 0; i < M; i++) {
    		edges[i].cost = scan.nextInt();
    	}
    	for (int i = 0; i < M; i++) {
    		edges[i].node1 = nodes[scan.nextInt()-1];
    		edges[i].node2 = nodes[scan.nextInt()-1];
    		edges[i].node1.connected.add(edges[i]);
    		edges[i].node2.connected.add(edges[i]);
    	}
    	Arrays.sort(edges);
    	int S = scan.nextInt();
    	long total = 0;
    	DisjointSet dis = new DisjointSet(N);
    	Edge[] tree = new Edge[N-1];
    	int index = 0;
    	for (Edge edge : edges) {
    		if (dis.union(edge.node1.id, edge.node2.id)) {
    			total += edge.weight;
    			tree[index++] = edge;
    			used[edge.id] = true;
    			if (index >= tree.length) {
    				break;
    			}
    		}
    	}
//    	for (Edge ed : tree) {
//			out.println((ed.node1.id+1)+" "+(ed.node2.id+1));
//		}
    	dfs(nodes[0], nodes[0], null);
    	int maxSave = 0;
    	Edge ex = null;
    	Edge in = null;
    	for (Edge edge : edges) {
    		int save = 0;
    		if (used[edge.id]) {
    			save = S/edge.cost;
    			if (save > maxSave) {
    				maxSave = save;
    				ex = edge;
    				in = edge;
    			}
    		} else {
    			Edge maxEdge = maxEdge(edge.node1, edge.node2);
    			save = S/edge.cost + maxEdge.weight - edge.weight;
    			if (save > maxSave) {
    				maxSave = save;
    				ex = maxEdge;
    				in = edge;
    			}
    		}
    	}
    	out.println(total-maxSave);
    	for (Edge edge : tree) {
    		if (edge != ex) {
        		out.println((edge.id+1)+" "+edge.weight);
    		}
    	}
		if (in != null) {
    		out.println((in.id+1)+" "+(in.weight-(S/in.cost)));
		}
    }
}