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

public class Main implements Runnable {

	public void _main() throws IOException {
		n = nextInt();
		volume = nextInt();
		int numEdges = nextInt();
		a = new int[n];		
		for (int i = 0; i < n; i++) {
			a[i] = nextInt();
		}
		b = new int[n];
		for (int i = 0; i < n; i++) {
			b[i] = nextInt();
		}
		g = new boolean[n][n];
		for (int i = 0; i < numEdges; i++) {
			int x = nextInt() - 1;
			int y = nextInt() - 1;
			g[x][y] = true;
			g[y][x] = true;
		}

		parent = new int[n];
		comp = new int[n];
		Arrays.fill(comp, -1);		
		for (int i = 0; i < n; i++) {
			if (comp[i] >= 0) continue;			
			sumA = 0;
			sumB = 0;
			computeTotalVolume(i);
			++numComps;
			if (sumA != sumB) {
				out.println("NO");
				return;
			}
			solveComponent(numComps - 1);
		}
		out.println(res.size());
		for (String s : res) {
			out.println(s);
		}
	}

	int n;
	int volume;
	boolean[][] g;
	int[] a;
	int[] b;
	int[] comp;
	int numComps;
	List<String> res = new ArrayList<String>();
	long sumA, sumB;
	int[] parent;

	private void solveComponent(int c) {
		int k = 0;
		for (int i = 0; i < n; i++) {
			if (comp[i] == c) {
				++k;
			}
		}
		int[] vs = new int[k];
		k = 0;
		for (int i = 0; i < n; i++) {
			if (comp[i] == c) {
				vs[k] = i; 
				++k;
			}
		}
		boolean ok = false;
		while (!ok) {
			ok = true;
			for (int v : vs) {
				if (a[v] <= b[v]) continue;
				ok = false;
				for (int u : vs) {
					parent[u] = -1;
				}
				parent[v] = v;
				dfs(v);
				int u = -1;
				for (int w : vs) {
					if (a[w] < b[w]) {
						u = w;
						break;
					}
				}
				if (u < 0) {
					throw new AssertionError();
				}
				int d = Math.min(a[v] - b[v], b[u] - a[u]);
				pour(v, u, d);
			}
		}
	}

	private void pour(int s, int t, int d) {
		if (s == t) return;
		int p = parent[t];
		int x = Math.min(d, a[p]);
		x = Math.min(x, volume - a[t]);
		add(p, t, x);
		pour(s, p, d);
		add(p, t, d - x);
	}

	private void add(int s, int t, int amount) {
		if (amount == 0) return;
		a[s] -= amount;
		a[t] += amount;
		res.add((s + 1) + " " + (t + 1) + " " + amount);
	}

	private void dfs(int i) {
		for (int j = 0; j < n; j++) {
			if (parent[j] < 0 && g[i][j]) {
				parent[j] = i;
				dfs(j);
			}
		}
	}

	private void computeTotalVolume(int i) {
		sumA += a[i];
		sumB += b[i];
		comp[i] = numComps;
		for (int j = 0; j < n; j++) {
			if (comp[j] < 0 && g[i][j]) {
				computeTotalVolume(j);
			}
		}
	}



	private BufferedReader in;
	private PrintWriter out;
	private StringTokenizer st;

	private String next() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String rl = in.readLine();
			if (rl == null)
				return null;
			st = new StringTokenizer(rl);
		}
		return st.nextToken();
	}

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

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

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

	public static void main(String[] args) {
		Locale.setDefault(Locale.UK);
		new Thread(new Main()).start();		
	}

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			//in = new BufferedReader(new FileReader("a.in"));
			//out = new PrintWriter(new FileWriter("a.out"));

			_main();

			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(202);
		}
	}

}