#include <bits/stdc++.h>
using namespace std;
const int M = 300 + 5;
long long int mod = 1000000000 + 7;
int adj[M][M];
int a[M];
int b[M];
vector<pair<pair<int, int>, int> > ans;
int vis[M];
vector<int> s;
int main() {
  time_t t_start, t_end;
  t_start = clock();
  int n, v, e;
  cin >> n >> v >> e;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < e; i++) {
    int x, y;
    cin >> x >> y;
    adj[x][y] = 1;
    adj[y][x] = 1;
  }
  int k = 0;
  bool ok = true;
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      queue<int> q;
      s.clear();
      q.push(i);
      vis[i] = 1;
      while (!q.empty()) {
        int u = q.front();
        s.push_back(u);
        q.pop();
        for (int j = 1; j <= n; j++) {
          if (adj[u][j] == 1 && !vis[j]) {
            int nxt = j;
            q.push(nxt);
            vis[nxt] = 1;
          }
        }
      }
      stack<pair<int, int> > pos;
      stack<pair<int, int> > neg;
      int sz = s.size();
      long long int sd = 0;
      for (int j = 0; j < sz; j++) {
        int d = a[s[j]] - b[s[j]];
        sd = sd + d;
        if (d > 0) {
          pos.push(make_pair(s[j], d));
        }
        if (d < 0) {
          neg.push(make_pair(s[j], -d));
        }
      }
      if (sd == 0) {
        while (!pos.empty() && !neg.empty()) {
          int pidx = pos.top().first;
          int pval = pos.top().second;
          int nidx = neg.top().first;
          int nval = neg.top().second;
          int dd = min(pval, nval);
          pos.pop();
          neg.pop();
          queue<int> qq;
          int father[M];
          vector<pair<int, int> > path;
          int visited[M];
          for (int j = 0; j < sz; j++) {
            visited[s[j]] = 0;
          }
          for (int j = 0; j < M; j++) {
            father[j] = 0;
          }
          qq.push(pidx);
          visited[pidx] = 1;
          while (!qq.empty()) {
            int u = qq.front();
            qq.pop();
            if (u == nidx) {
              break;
            }
            for (int j = 1; j <= n; j++) {
              if (adj[u][j] == 1 && !visited[j]) {
                qq.push(j);
                visited[j] = 1;
                father[j] = u;
              }
            }
          }
          int tmp = nidx;
          while (tmp != 0) {
            path.push_back(make_pair(tmp, a[tmp]));
            tmp = father[tmp];
          }
          stack<pair<pair<int, int>, int> > res;
          int sz = path.size();
          for (int j = 0; j + 1 < sz; j++) {
            int cur = path[j].first;
            int curval = path[j].second;
            int far = path[j + 1].first;
            int farval = path[j + 1].second;
            if (farval >= dd) {
              ans.push_back(make_pair(make_pair(far, cur), dd));
            } else {
              ans.push_back(make_pair(make_pair(far, cur), farval));
              res.push(make_pair(make_pair(far, cur), dd - farval));
            }
          }
          while (!res.empty()) {
            ans.push_back(res.top());
            res.pop();
          }
          if (pval > dd) {
            pos.push(make_pair(pidx, pval - dd));
          }
          if (nval > dd) {
            neg.push(make_pair(nidx, nval - dd));
          }
          a[pidx] = a[pidx] - dd;
          a[nidx] = a[nidx] + dd;
        }
      } else {
        ok = false;
        break;
      }
    }
  }
  if (!ok) {
    cout << "NO" << endl;
  } else {
    int sz = ans.size();
    cout << sz << endl;
    for (int i = 0; i < sz; i++) {
      cout << ans[i].first.first << " " << ans[i].first.second << " "
           << ans[i].second << endl;
    }
  }
  t_end = clock();
  return 0;
}
