Problem: A system of n vessels with water is given. Several pairs of vessels are connected by tubes with transfusion mechanisms. One may transfer an integer amount of liters of water between two vessels connected by such tube (tube works in both directions). There might be multiple tubes between two vessels. Total number of tubes equals e. Volume of each vessel equals v liters. Of course, the amount of the water in any vessel cannot exceed v liters in the process of transfusions.

Given the initial amounts ai of water in the vessels and the desired amounts bi find a sequence of transfusions that deals with the task. Total number of transfusions must not exceed 2·n2.

Input

First line of the input contains integers n, v, e (1 ≤ n ≤ 300, 1 ≤ v ≤ 109, 0 ≤ e ≤ 50000).

Next two lines contain n integers each: initial ai and the desired amounts bi of water in corresponding vessels (0 ≤ ai, bi ≤ v).

Next e lines describe one tube each in the format x y (1 ≤ x, y ≤ n, x ≠ y) for a tube between vessels number x and y. There might be multiple tubes between two vessels. You may assume that vessels are numbered from 1 to n in some way.

Output

Print "NO" (without quotes), if such sequence of transfusions does not exist.

Otherwise print any suitable sequence in the following format. On the first line print the total number of transfusions k (k should not exceed 2·n2). In the following k lines print transfusions in the format x y d (transfusion of d liters from the vessel number x to the vessel number y, x and y must be distinct). For all transfusions d must be a non-negative integer.

Examples

Input

2 10 1
1 9
5 5
1 2


Output

1
2 1 4


Input

2 10 0
5 2
4 2


Output

NO


Input

2 10 0
4 2
4 2


Output

0

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;


public class Main {
	static int N, V, E;
	static int[] a, f, b;
	static int[][] P;
	static boolean[] v;
	static ArrayList<String> ret = new ArrayList<String>();
	public static void main(String[] args) throws Exception {
		InputReader r = new InputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		N = r.nextInt();
		V = r.nextInt();
		E = r.nextInt();
		
		f = new int[N];
		a = new int[N];
		b = new int[N];
		for(int i = 0; i < N; i++){
			f[i] = r.nextInt(); 
			a[i] = f[i];
		}
		
		for(int i = 0; i < N; i++){
			b[i] = r.nextInt();
			a[i] -= b[i];
		}
		
		P = new int[N][N];
		for(int i = 0; i < N; i++){
			Arrays.fill(P[i], -1);
			P[i][i] = i;
		}
		
		for(int z = 0; z < E; z++){
			int x = r.nextInt() - 1;
			int y = r.nextInt() - 1;
			
			P[x][y] = y;
			P[y][x] = x;
		}
		
		for(int k = 0; k < N; k++)
		for(int i = 0; i < N; i++)
		for(int j = 0; j < N; j++)if(P[i][k] != -1 && P[k][j] != -1 && P[i][j] == -1)
			P[i][j] = P[i][k];
			
		v = new boolean[N];
		
		for(int i = 0; i < N; i++)if(!v[i]){
			long s = 0;
			
			Stack<Integer> sp = new Stack<Integer>();
			Stack<Integer> sv = new Stack<Integer>();
			
			for(int j = 0; j < N; j++)if(P[i][j] != -1){
				v[j] = true;
				if(a[j] > 0)sp.push(j);
				else if(a[j] < 0)sv.push(j);
				
				s += a[j];
			}
			
			if(s != 0){
				out.println("NO");
				out.close();
				return;
			}
			
			while(!sp.isEmpty()){
				int np = sp.pop();
				int nv = sv.pop();
				
				int d = Math.min(a[np], -a[nv]);

				int op = f[np];
				int ov = f[nv];
				
				fix(np, nv, d);
				
				a[np] -= d;
				a[nv] += d;
				
				if(a[np] != 0)sp.push(np);
				if(a[nv] != 0)sv.push(nv);
			}
		}
		
		out.println(ret.size());
		for(String s : ret)
			out.println(s);
		out.close();
	}
	
	private static void fix(int x, int y, int d) throws Exception {
		if(x == y)return;
		
		int next = P[x][y];
		
		if(f[next] + d <= V){
			f[next] += d;
			f[x] -= d;
			ret.add(String.format("%d %d %d", x + 1, next + 1, d));
			fix(next, y, d);
		}else{
			int can = V - f[next];
			
			f[next] += can;
			f[x] -= can;
			ret.add(String.format("%d %d %d", x + 1, next + 1, can));
			fix(next, y, d);
			
			f[next] += d - can;
			f[x] -= d - can;
			ret.add(String.format("%d %d %d", x + 1, next + 1, d - can));
		}
	}

	static class InputReader {
	    private BufferedReader reader;
	    private StringTokenizer tokenizer;

	    public InputReader(InputStream stream) {
	        reader = new BufferedReader(new InputStreamReader(stream));
	        tokenizer = null;
	    }

	    public String nextLine(){
	    	try {
				return reader.readLine();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;
			}
	    }
	    public String next() {
	        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public int nextInt() {
	        return Integer.parseInt(next());
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	}
}