#include <bits/stdc++.h>
using namespace std;
int n, v, e, ee, a[305], b[305], head[305], ansa[90005], ansb[90005],
    ansc[90005], aa, bef[305], T, flag, vis[305], II, tt;
struct Edge {
  int to, next;
} edge[100005];
inline void addedge(int x, int y) {
  edge[++ee].to = y;
  edge[ee].next = head[x];
  head[x] = ee;
}
void dfs(int x, int fr) {
  bef[x] = fr;
  vis[x] = II;
  if (flag) return;
  if (b[x] > a[x]) {
    flag = 1;
    T = x;
    return;
  };
  for (int i = head[x]; i != -1; i = edge[i].next)
    if (edge[i].to != fr && vis[edge[i].to] != II) dfs(edge[i].to, x);
}
inline void addf(int s, int t, int ff) {
  ansa[++aa] = s, ansb[aa] = t, ansc[aa] = ff;
}
void work(int s, int t, int ff) {
  if (bef[t] == s) {
    addf(s, t, ff);
    return;
  }
  int ha = min(ff, a[bef[t]]);
  addf(bef[t], t, ha);
  work(s, bef[t], ff);
  if (ha != ff) addf(bef[t], t, ff - ha);
}
int main() {
  scanf("%d%d%d", &n, &v, &e);
  memset(head, -1, sizeof(head));
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= e; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    addedge(x, y);
    addedge(y, x);
  }
  for (int i = 1; i <= n; i++) {
    while (a[i] > b[i]) {
      flag = 0;
      II = ++tt;
      dfs(i, 0);
      if (!flag) {
        puts("NO");
        return 0;
      }
      int ha = min(a[i] - b[i], b[T] - a[T]);
      work(i, T, ha);
      a[i] -= ha;
      a[T] += ha;
    }
  }
  for (int i = 1; i <= n; i++)
    if (a[i] != b[i]) {
      puts("NO");
      return 0;
    }
  cout << aa << endl;
  for (int i = 1; i <= aa; i++) printf("%d %d %d\n", ansa[i], ansb[i], ansc[i]);
  return 0;
}
