#include <bits/stdc++.h>
using namespace std;
int a[310], b[310];
int n, v, e;
bool vis[310];
vector<int> near[310];
vector<int> p;
bool f;
vector<pair<pair<int, int>, int> > out;
void rec(int pos, int req) {
  int rem = min(req, a[p[pos]]);
  if (rem) out.push_back(make_pair((make_pair((p[pos]), (p[pos + 1]))), (rem)));
  if (pos) rec(pos - 1, req);
  rem = req - rem;
  if (rem) out.push_back(make_pair((make_pair((p[pos]), (p[pos + 1]))), (rem)));
}
void dfs(int now, int root) {
  p.push_back(now);
  vis[now] = true;
  if (a[now] < b[now] && a[root] > b[root]) {
    int v = min(b[now] - a[now], a[root] - b[root]);
    rec(p.size() - 2, v);
    a[now] += v;
    a[root] -= v;
  }
  for (int x : near[now])
    if (!vis[x]) dfs(x, root);
  p.pop_back();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> v >> e;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < e; i++) {
    int u, v;
    cin >> u >> v;
    near[--u].push_back(--v);
    near[v].push_back(u);
  }
  for (int i = 0; i < n; i++) {
    if (a[i] > b[i]) {
      fill(vis, vis + n, 0);
      dfs(i, i);
    }
  }
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) f = true;
  if (f)
    cout << "NO" << endl;
  else {
    cout << out.size() << endl;
    for (pair<pair<int, int>, int> &x : out)
      cout << ++x.first.first << " " << ++x.first.second << " " << x.second
           << endl;
  }
  return 0;
}
