Problem: A system of n vessels with water is given. Several pairs of vessels are connected by tubes with transfusion mechanisms. One may transfer an integer amount of liters of water between two vessels connected by such tube (tube works in both directions). There might be multiple tubes between two vessels. Total number of tubes equals e. Volume of each vessel equals v liters. Of course, the amount of the water in any vessel cannot exceed v liters in the process of transfusions.

Given the initial amounts ai of water in the vessels and the desired amounts bi find a sequence of transfusions that deals with the task. Total number of transfusions must not exceed 2·n2.

Input

First line of the input contains integers n, v, e (1 ≤ n ≤ 300, 1 ≤ v ≤ 109, 0 ≤ e ≤ 50000).

Next two lines contain n integers each: initial ai and the desired amounts bi of water in corresponding vessels (0 ≤ ai, bi ≤ v).

Next e lines describe one tube each in the format x y (1 ≤ x, y ≤ n, x ≠ y) for a tube between vessels number x and y. There might be multiple tubes between two vessels. You may assume that vessels are numbered from 1 to n in some way.

Output

Print "NO" (without quotes), if such sequence of transfusions does not exist.

Otherwise print any suitable sequence in the following format. On the first line print the total number of transfusions k (k should not exceed 2·n2). In the following k lines print transfusions in the format x y d (transfusion of d liters from the vessel number x to the vessel number y, x and y must be distinct). For all transfusions d must be a non-negative integer.

Examples

Input

2 10 1
1 9
5 5
1 2


Output

1
2 1 4


Input

2 10 0
5 2
4 2


Output

NO


Input

2 10 0
4 2
4 2


Output

0

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
static const int INF = 500000000;
template <class T>
void debug(T a, T b) {
  for (; a != b; ++a) cerr << *a << ' ';
  cerr << endl;
}
bool g[305][305];
int flow[305][305];
int cap;
int n, m;
struct uf {
  int par[305];
  uf() { memset(par, -1, sizeof(par)); }
  int root(int a) {
    if (par[a] == -1) return a;
    return par[a] = root(par[a]);
  }
  void unite(int a, int b) {
    a = root(a);
    b = root(b);
    if (a == b) return;
    par[a] = b;
  }
  bool same(int a, int b) { return root(a) == root(b); }
};
uf u;
int have[305], want[305];
int vis[305];
long long int haveS[305], wantS[305];
pair<pair<int, int>, int> ans[1000005];
int acnt;
int path[305], n2;
bool findpath(int s, int t) {
  if (s == t) {
    path[n2++] = t;
    return true;
  }
  vis[s] = 1;
  for (int i = 0; i < n; ++i)
    if (g[s][i] && !vis[i]) {
      if (findpath(i, t)) {
        path[n2++] = s;
        return true;
      }
    }
  return false;
};
void solve(int i, int j, int d) {
  if (i == j) return;
  int t_ = path[j - 1], t = path[j];
  int delta = min(d, have[t_]);
  if (delta > 0) {
    ans[acnt++] = make_pair(make_pair(t_, t), delta);
    have[t] += delta;
    have[t_] -= delta;
  }
  solve(i, j - 1, d);
  int rest = d - delta;
  if (rest > 0) {
    ans[acnt++] = make_pair(make_pair(t_, t), rest);
    have[t] += rest;
    have[t_] -= rest;
  }
}
int main() {
  cin >> n >> cap >> m;
  for (int i = 0; i < n; ++i) scanf("%d", &have[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &want[i]);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a;
    --b;
    g[a][b] = g[b][a] = 1;
    u.unite(a, b);
  }
  for (int i = 0; i < n; ++i)
    haveS[u.root(i)] += have[i], wantS[u.root(i)] += want[i];
  int fail = 0;
  for (int i = 0; i < n; ++i)
    if (haveS[i] != wantS[i]) fail = 1;
  if (fail) {
    puts("NO");
    return 0;
  }
  bool changed = true;
  while (changed) {
    changed = false;
    for (int i = 0; i < n; ++i)
      if (have[i] != want[i]) {
        for (int j = 0; j < n; ++j)
          if (have[j] != want[j] && u.same(i, j) &&
              (have[i] < want[i]) ^ (have[j] < want[j])) {
            int s, t, d;
            if (have[i] < want[i]) {
              t = i;
              s = j;
              d = min(want[i] - have[i], have[j] - want[j]);
            } else {
              t = j;
              s = i;
              d = min(have[i] - want[i], want[j] - have[j]);
            }
            memset(vis, 0, sizeof(vis));
            n2 = 0;
            findpath(s, t);
            reverse(path, path + n2);
            solve(0, n2 - 1, d);
            changed = true;
            goto exi;
          }
      }
  exi:;
  }
  printf("%d\n", acnt);
  for (int i = 0; i < acnt; ++i) {
    printf("%d %d %d\n", ans[i].first.first + 1, ans[i].first.second + 1,
           ans[i].second);
  }
  return 0;
}