#include <bits/stdc++.h>
using namespace std;
vector<int> G[310];
vector<pair<int, pair<int, int> > > sol;
int n, v, e;
int viz[310];
int A[310], B[310], T[310];
long long s1 = 0, s2 = 0;
int S;
void df(int x) {
  s1 += A[x];
  s2 += B[x];
  viz[x] = 1;
  for (vector<int>::iterator it = G[x].begin(); it != G[x].end(); it++) {
    if (!viz[*it]) {
      df(*it);
    }
  }
}
void poor(int s, int t, int d) {
  if (s == t) return;
  int tata = T[t];
  int p = min(B[tata], d);
  pair<int, pair<int, int> > c = make_pair(p, make_pair(tata, t));
  sol.push_back(c);
  B[tata] -= p;
  B[t] += p;
  poor(s, tata, d);
  pair<int, pair<int, int> > p2 = make_pair(d - p, make_pair(tata, t));
  B[tata] -= d - p;
  B[t] += d - p;
  if (d != p) sol.push_back(p2);
}
void df2(int x) {
  viz[x] = 1;
  if (A[S] == B[S]) return;
  if (B[x] < A[x]) poor(S, x, min(A[x] - B[x], B[S] - A[S]));
  for (vector<int>::iterator i = G[x].begin(); i != G[x].end(); i++) {
    if (!viz[*i]) {
      T[*i] = x;
      df2(*i);
    }
  }
}
void toarna(int x) {
  memset(viz, 0, sizeof(viz));
  S = x;
  df2(x);
}
int main() {
  scanf("%d%d%d", &n, &v, &e);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &B[i]);
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &A[i]);
  }
  for (int i = 1; i <= e; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x].push_back(y);
    G[y].push_back(x);
  }
  for (int i = 1; i <= n; i++) {
    if (!viz[i]) {
      s1 = s2 = 0;
      df(i);
      if (s1 != s2) {
        printf("NO\n");
        return 0;
      }
    }
  }
  memset(viz, 0, sizeof(viz));
  for (int i = 1; i <= n; i++) {
    if (B[i] > A[i]) {
      toarna(i);
    }
  }
  printf("%d\n", sol.size());
  for (size_t i = 0; i < sol.size(); i++) {
    printf("%d %d %d\n", sol[i].second.first, sol[i].second.second,
           sol[i].first);
  }
  return 0;
}
