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.BigInteger;
import static java.lang.Math.*;
import static java.math.BigInteger.*;

public class Main {

    BufferedReader br;
    StringTokenizer in;
    PrintWriter out;

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

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

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

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() throws IOException {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        Reader reader = oj ? new InputStreamReader(System.in) :
                new FileReader("input.txt");
        br = new BufferedReader(reader);
        out = new PrintWriter(
                oj ? new OutputStreamWriter(System.out) :
                        new FileWriter("output.txt"));
        solve();
        //deb();
        out.flush();
    }


    int n, v, e;
    int[] a, b;
    boolean[][] gr;
    ArrayList<String> ans = new ArrayList<>();

    HashSet<Integer> comp;
    boolean[] IsU;
    void dfs( int v ){
        if( IsU[v] ) return;
        IsU[v] = true;
        comp.add(v);
        for( int to = 0; to < n; ++to )
            if( gr[v][to] )
                dfs(to);
    }

    boolean[] u;
    Vector<Integer> path;
    int last;
    boolean getPath( int v ){
        if( u[v] ) return false;
        u[v] = true;
        if( v == last ){
            path.add(v);
            return true;
        }
        for( int to = 0; to < n; ++to ){
            if( gr[v][to] && getPath(to) ){
                path.add(v);
                return true;
            }
        }
        return false;
    }

    void fun( int j, int d ){
        int v = path.get(j);
        String vTO =
            (path.get(j)  +1) +" "+
            (path.get(j+1)+1) +" ";
        if( a[v] < d )
            ans.add( vTO + a[v] );
        else
            ans.add( vTO + d );
        if( j!=0 ) fun( j-1, d );
        if( a[v] < d )
            ans.add( vTO + (d-a[v]) );
    }

    boolean doSome(){
        long sumA = 0, sumB = 0;
        for( int v : comp ){
            sumA += a[v];
            sumB += b[v];
        }
        if( sumA != sumB ) return false;
        while( !comp.isEmpty() ){
            int v=-1, to=-1, d;
            for( Integer i : comp ){
                if( a[i] > b[i] ) v =i;
                if( a[i] < b[i] ) to=i;
            }
            if( v == -1 ) break;
            d = min( a[v]-b[v], b[to]-a[to] );

            last = to;
            u = new boolean[n];
            path = new Vector<>();
            getPath(v);
            Collections.reverse(path);
            fun( path.size()-2, d);

            a[v ] -= d;
            a[to] += d;
            if( a[v ]==b[v ] ) comp.remove(v );
            if( a[to]==b[to] ) comp.remove(to);

        }

        return true;
    }

    void solve() throws IOException{
labelSolve:
    {
        n = nextInt();
        v = nextInt();
        e = nextInt();
        gr = new boolean[n][n];
        a = new int[n];
        b = new int[n];
        for( int i = 0; i < n; ++i ) a[i] = nextInt();
        for( int i = 0; i < n; ++i ) b[i] = nextInt();
        for( int i = 0; i < e; ++i ){
            int a = nextInt()-1;
            int b = nextInt()-1;
            gr[a][b] = true;
            gr[b][a] = true;
        }

        IsU = new boolean[n];
        for( int i = 0; i < n; ++i ){
            comp = new HashSet<>();
            if( !IsU[i] ){
                dfs(i);
                if( !doSome() ){
                    out.println("NO");
                    return;
                }
            }
        }
        out.println(ans.size());
        for(String s : ans) out.println(s);
    }
    }



}