#include <bits/stdc++.h>
using namespace std;
const int Inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fll;
int n, v, e;
vector<int> nei[333];
int a[333], b[333];
bool lgl[333];
int fa[333];
int dfs(int now) {
  lgl[now] = 1;
  if (a[now] < b[now]) return now;
  for (int i = 0; i < (((int)(nei[now]).size())); ++i) {
    int to = nei[now][i];
    if (lgl[to]) continue;
    fa[to] = now;
    int v = dfs(to);
    if (v) return v;
  }
  return 0;
}
struct Oper {
  int u, v, w;
  Oper(int u, int v, int w) : u(u), v(v), w(w) {}
};
vector<Oper> res;
void inline make(int u, int v, int w) {
  res.push_back(Oper(u, v, w));
  a[u] -= w;
  a[v] += w;
}
void trying(int s, int t, int f) {
  if (s == t) return;
  int u = fa[t];
  int r = a[u], fl = min(r, f);
  make(u, t, fl);
  trying(s, u, f);
  if (a[u] > r) make(u, t, a[u] - r);
}
int main() {
  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);
  for (int i = 1; i <= (e); ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    nei[u].push_back(v);
    nei[v].push_back(u);
  }
  int mdf = 0;
  for (int i = 1; i <= (n); ++i)
    if (a[i] != b[i]) ++mdf;
  while (mdf) {
    int sel = 0;
    for (int i = 1; i <= (n); ++i)
      if (a[i] > b[i]) {
        sel = i;
        break;
      }
    if (!sel) return puts("NO"), 0;
    memset(lgl, 0, sizeof(lgl));
    int to = dfs(sel);
    if (!to) return puts("NO"), 0;
    int go = min(a[sel] - b[sel], b[to] - a[to]);
    trying(sel, to, go);
    mdf -= !(a[sel] - b[sel]);
    mdf -= !(a[to] - b[to]);
  }
  printf("%d\n", ((int)(res).size()));
  for (int i = 0; i < (((int)(res).size())); ++i)
    printf("%d %d %d\n", res[i].u, res[i].v, res[i].w);
  return 0;
}
