#include <bits/stdc++.h>   using namespace std;   const double PI = 2.0 * acos(0.0);   const double EPS = 1e-6;   int a[455];   int b[455];   vector<int> G[455];   int boss[455];   void init() {     for (int i = 1; i < 455; i++) boss[i] = i;   }   int find_boss(int x) {     return boss[x] = (boss[x] == x ? x : find_boss(boss[x]));   }   bool unite(int x, int y) {     int bx = find_boss(x);     int by = find_boss(y);     if (bx == by) return false;     boss[bx] = by;     return true;   }   vector<pair<pair<int, int>, int> > res;   int pour(int from, int to, int d) {     int flow = min(d, max(a[to] - b[to], 0));     a[to] -= flow;     int pos = ((int)(res).size());     for (int i = 0; flow < d && i < ((int)(G[to]).size()); i++) {       int v = G[to][i];       if (v == from) continue;       flow += pour(to, v, d - flow);     }     if (from != -1) {       int po = min(a[to], flow);       if (po > 0)         res.insert(res.begin() + pos, make_pair(make_pair(to, from), po));       if (po < flow) res.push_back(make_pair(make_pair(to, from), flow - po));     }     return flow;   }   int main() {     int n, v, e;     scanf( %d %d %d , &n, &v, &e);     for (int i = 1; i <= n; i++) scanf( %d , a + i);     for (int i = 1; i <= n; i++) scanf( %d , b + i);     init();     while (e--) {       int x, y;       scanf( %d %d , &x, &y);       if (unite(x, y)) {         G[x].push_back(y);         G[y].push_back(x);       }     }     for (int i = 1; i <= n; i++)       if (a[i] < b[i]) a[i] += pour(-1, i, b[i] - a[i]);     for (int i = 1; i <= n; i++)       if (a[i] != b[i]) return puts( NO ), 0;     printf( %d n , ((int)(res).size()));     for (__typeof((res).begin()) itr = (res).begin(); itr != (res).end(); itr++)       printf( %d %d %d n , itr->first.first, itr->first.second, itr->second);     return 0;   }   