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
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.List;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        int[] firstEdge;
        int[] nextEdge;
        int[] to;
        int[] have;
        int[] need;
        int[] prev;
        List<Transfusion> fans = new ArrayList<>();

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), v = in.nextInt(), m = in.nextInt();
            firstEdge = new int[n];
            Arrays.fill(firstEdge, -1);
            nextEdge = new int[2 * m];
            to = new int[2 * m];
            have = new int[n];
            need = new int[n];
            prev = new int[n];

            for (int i = 0; i < n; ++i) have[i] = in.nextInt();
            for (int i = 0; i < n; ++i) need[i] = in.nextInt();
            for (int i = 0; i < m; ++i) {
                int x = in.nextInt() - 1, y = in.nextInt() - 1;
                to[2 * i] = y;
                nextEdge[2 * i] = firstEdge[x];
                firstEdge[x] = 2 * i;

                to[2 * i + 1] = x;
                nextEdge[2 * i + 1] = firstEdge[y];
                firstEdge[y] = 2 * i + 1;
            }

            while (true) {
                int node = 0;
                while (node < n && have[node] >= need[node])
                    ++node;

                if (node == n) break;

                Arrays.fill(prev, -1);
                prev[node] = -2;
                int dest = dfs(node);
                if (dest == -1) break;

                int flow = Math.min(need[node] - have[node],
                        have[dest] - need[dest]);

                pushFlow(dest, node, flow);
            }

            for (int i = 0; i < n; ++i) {
                if (have[i] != need[i]) {
                    out.println("NO");
                    return;
                }
            }
            out.println(fans.size());
            for (Transfusion p : fans) {
                out.println((p.from + 1) + " " + (p.to + 1) + " " + p.flow);
            }
        }

        private void push(int from, int to, int flow) {
            have[from] -= flow;
            have[to] += flow;
            fans.add(new Transfusion(from, to, flow));
        }

        private void pushFlow(int from, int to, int flow) {
            int n = prev[from];
            if (n == to) {
                push(from, to, flow);
            } else {
                int remFlow = flow;
                if (have[n] < flow) {
                    int diff = flow - have[n];
                    push(from, n, diff);
                    remFlow -= diff;
                }
                pushFlow(n, to, flow);
                push(from, n, remFlow);
            }
        }

        private int dfs(int node) {
            if (have[node] > need[node]) {
                return node;
            }
            for (int p = firstEdge[node]; p != -1; p = nextEdge[p]) {
                int to = this.to[p];
                if (prev[to] == -1) {
                    prev[to] = node;
                    int x = dfs(to);
                    if (x != -1) return x;
                }
            }
            return -1;
        }

        private class Transfusion {
            int from;
            int to;
            int flow;

            Transfusion(int from, int to, int flow) {
                this.from = from;
                this.to = to;
                this.flow = flow;
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

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

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}

