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.InputStreamReader;
import java.util.StringTokenizer;

public class ProblemC {
    int n;
    long v;
    boolean[][] adj;
    int[] deg;
    boolean[] used;
    long[] have, need;
    int ops;
    StringBuilder res = new StringBuilder();

    public void doIt(int from, int to, long cnt) {
        have[from] -= cnt;
        have[to] += cnt;
        ops++;
        res.append((from+1) + " " + (to+1) + " " + cnt + "\n");
    }

    void sinkUp(int pos, int parent) {
        for (int i=0; i < n; i++)
            if (adj[pos][i] && i != parent) {
                sinkUp(i, pos);
                doIt(i, pos, Math.min(have[i], v - have[pos]));
            }
    }

    void sinkDown(int pos, int parent) {
        for (int i=0; i < n; i++)
            if (adj[pos][i] && i != parent) {
                sinkDown(i, pos);
                doIt(pos, i, Math.min(have[pos], v - have[i]));
            }
    }

    public void doMain() throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        n = Integer.parseInt(st.nextToken());
        v = Integer.parseInt(st.nextToken());
        int e = Integer.parseInt(st.nextToken());
        int[] id = new int[n];
        for (int i=0; i<n; i++) {
            id[i] = i;
        }
        have = new long[n]; need = new long[n];
        st = new StringTokenizer(br.readLine());
        for (int i=0; i<n; i++) {
            have[i] = Integer.parseInt(st.nextToken());
        }
        st = new StringTokenizer(br.readLine());
        for (int i=0; i<n; i++) {
            need[i] = Integer.parseInt(st.nextToken());
        }
        used = new boolean[n];
        adj = new boolean[n][n];
        deg = new int[n];
        for (int i=0; i<e; i++) {
            st = new StringTokenizer(br.readLine());
            int x = Integer.parseInt(st.nextToken());
            int y = Integer.parseInt(st.nextToken());
            x--; y--;
            if (id[x] != id[y]) {
                deg[x]++; deg[y]++;
                adj[x][y] = adj[y][x] = true;
                int idx = id[x], idy = id[y];
                for (int t=0; t<n; t++) if (id[t] == idx) id[t] = idy;
            }
        }
        br.close();

        long[] sumHave = new long[n];
        long[] sumNeed = new long[n];
        for (int i=0; i<n; i++) {
            sumHave[id[i]] += have[i];
            sumNeed[id[i]] += need[i];
        }
        for (int i=0; i<n; i++)
            if (sumHave[i] != sumNeed[i]) {
                System.out.println("NO");
                System.exit(0);
            }

        while (true) {
            int leaf = 0;
            while (leaf < n && (used[leaf] || deg[leaf] != 1)) leaf++;
            if (leaf == n) break;
            int parent = 0;
            while (!adj[leaf][parent]) parent++;
            if (have[leaf] < need[leaf]) {
                sinkUp(parent, leaf);
                doIt(parent, leaf, need[leaf] - have[leaf]);
            } else if (have[leaf] > need[leaf]) {
                sinkDown(parent, leaf);
                doIt(leaf, parent, have[leaf] - need[leaf]);
            }
            adj[leaf][parent] = adj[parent][leaf] = false;
            deg[parent]--; deg[leaf]--;
        }

        System.out.println(ops);
        System.out.println(res);
    }
    public static void main(String[] args) throws Exception {
        new ProblemC().doMain();
    }
}