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 dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
long long powmod(long long a, long long b) {
  long long tmp = 1;
  a %= (10000000000);
  for (; b; b >>= 1) {
    if (b & 1) tmp = tmp * a % (10000000000);
    a = a * a % (10000000000);
  }
  return tmp;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <class T>
inline void R(T &xx) {
  xx = 0;
  char ch = getchar();
  bool F = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') F = 1, ch = getchar();
  while (ch >= '0' && ch <= '9')
    xx = xx + xx + (xx << 3) + ch - 48, ch = getchar();
  if (F) xx = -xx;
}
template <class T>
inline void add(int &x, T y) {
  for (x += y; x >= (10000000000); x -= (10000000000))
    ;
}
vector<pair<pair<int, int>, int> > ans;
vector<int> g[333];
int vis[333], q[333], dis[333], pre[333], Ti;
int a[333], b[333], f[333], n, v, e;
long long s[333];
void bfs(int S) {
  memset(dis, 0, sizeof(dis));
  q[1] = S;
  vis[S] = ++Ti;
  for (int h(0), t(1); h < t;) {
    int u = q[++h];
    for (int i = 0; i < (int)((int)g[u].size()); i++)
      if (vis[g[u][i]] != Ti) {
        vis[g[u][i]] = Ti;
        dis[g[u][i]] = dis[u] + 1;
        pre[q[++t] = g[u][i]] = u;
      }
  }
}
int find(int x) { return (f[x] == x) ? f[x] : f[x] = find(f[x]); }
void flow(int s, int t, int d) {
  if (s == t) return;
  int nw = min(min(a[pre[t]], v - a[t]), d);
  a[pre[t]] -= nw;
  a[t] += nw;
  if (nw) ans.push_back(make_pair(make_pair(pre[t], t), nw));
  flow(s, pre[t], d);
  a[pre[t]] -= d - nw;
  a[t] += d - nw;
  if (d - nw) ans.push_back(make_pair(make_pair(pre[t], t), d - nw));
}
int main() {
  R(n);
  R(v);
  R(e);
  for (int i = 1; i <= n; i++) R(a[i]), f[i] = i;
  for (int i = 1; i <= n; i++) R(b[i]);
  for (int x, y; e--;)
    R(x), R(y), g[x].push_back(y), g[y].push_back(x), f[find(x)] = find(y);
  for (int i = 1; i <= n; i++) s[find(i)] += a[i] - b[i];
  for (int i = 1; i <= n; i++)
    if (s[i]) return puts("NO"), 0;
  for (int i = 1; i <= n; i++) {
    bfs(i);
    for (int t; a[i] > b[i]; flow(i, t, min(a[i] - b[i], b[t] - a[t])))
      for (int j = 1; j <= n; j++)
        if (dis[j] && a[j] < b[j]) {
          t = j;
          break;
        }
  }
  printf("%d\n", ((int)ans.size()));
  for (int i = 0; i < (int)((int)ans.size()); i++)
    printf("%d %d %d\n", ans[i].first.first, ans[i].first.second,
           ans[i].second);
  return 0;
}