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;
const int maxn = 10100;
int fa[maxn];
int fin(int n) {
  if (fa[n] == n) return n;
  return fa[n] = fin(fa[n]);
}
int first[maxn], nxt[maxn], vv[maxn], vis[maxn], now[maxn], mu[maxn];
queue<int> q;
int jud(int n) {
  long long ans = 0;
  int u, v, e;
  q.push(n);
  vis[n] = 1;
  while (!q.empty()) {
    u = q.front();
    ans += now[u] - mu[u];
    q.pop();
    e = first[u];
    while (e) {
      v = vv[e];
      if (!vis[v]) {
        q.push(v);
        vis[v] = 1;
      }
      e = nxt[e];
    }
  }
  return ans == 0;
}
pair<pair<int, int>, long long> lst[1100];
pair<pair<int, int>, long long> ans[200010];
int cnt;
long long dfs(int n, int f) {
  long long need = mu[n] - now[n];
  for (int e = first[n]; e; e = nxt[e])
    if (vv[e] - f) need += dfs(vv[e], n);
  if (need < 0)
    lst[++cnt] = make_pair(make_pair(n, f), -need);
  else if (need > 0)
    lst[++cnt] = make_pair(make_pair(f, n), need);
  return need;
}
long long val;
int num;
void out(int n) {
  int i, j, k, is = 0, u, v;
  long long t, o;
  while (1) {
    is = 0;
    for (i = 1; i <= cnt; i++)
      if (lst[i].second) {
        u = lst[i].first.first;
        v = lst[i].first.second;
        t = lst[i].second;
        o = min(min(now[u] + 0ll, val - now[v]), t + 0ll);
        if (o) {
          now[u] -= o;
          now[v] += o;
          lst[i].second -= o;
          is = 1;
          ans[++num] = make_pair(make_pair(u, v), o);
        }
      }
    if (!is) break;
  }
  cout << num << endl;
  for (i = 1; i <= num; i++)
    printf("%d %d %d\n", ans[i].first.first, ans[i].first.second,
           ans[i].second);
}
int main() {
  int n, m, i, j, k;
  cin >> n >> val >> m;
  for (i = 1; i <= n; i++) fa[i] = i;
  for (i = 1; i <= n; i++) cin >> now[i];
  for (i = 1; i <= n; i++) {
    cin >> mu[i];
    if (mu[i] > val || now[i] > val) {
      cout << "NO" << endl;
      return 0;
    }
  }
  int e = 2;
  while (m--) {
    cin >> i >> j;
    if (fin(i) - fin(j)) {
      fa[fin(i)] = j;
      nxt[e] = first[i], vv[e] = j, first[i] = e++;
      nxt[e] = first[j], vv[e] = i, first[j] = e++;
    }
  }
  for (i = 1; i <= n; i++)
    if (!vis[i]) {
      if (!jud(i)) {
        puts("NO");
        return 0;
      }
      dfs(i, 0);
    }
  out(n);
}