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;
inline int in() {
  int32_t x;
  scanf("%d", &x);
  return x;
}
inline long long lin() {
  long long x;
  scanf("%lld", &x);
  return x;
}
char ch[4000010];
inline string get() {
  scanf("%s", ch);
  return string(ch);
}
inline void read(int *a, int n) {
  for (int i = 0; i < n; i++) a[i] = in();
}
template <class blank>
inline void out(blank x) {
  cout << x << "\n";
  exit(0);
}
template <class blank, class blank2>
inline void smin(blank &a, blank2 b) {
  a = a <= b ? a : b;
}
template <class blank, class blank2>
inline void smax(blank &a, blank2 b) {
  a = a >= b ? a : b;
}
const int maxn = 1e3 + 10;
const int maxm = 4e6 + 10;
const int maxlg = 20;
const int base = 29;
const int mod = 1e9 + 7;
const long long inf = 1e9 + 10;
const double eps = 1e-4;
int a[maxn], b[maxn];
vector<int> g[maxn];
bool mark[maxn];
int f, s;
vector<int> V[maxn];
int where[maxn];
int cmp;
int q[maxn], t, h, di[maxn], pre[maxn];
inline void bfs(int node) {
  t = 1, h = 0;
  q[0] = node;
  for (int i = 0; i <= 310; i++) di[i] = inf;
  di[node] = 0;
  while (h < t) {
    int v = q[h++];
    for (auto u : g[v]) {
      if (di[u] >= inf) {
        di[u] = di[v] + 1, q[t++] = u;
        pre[u] = v;
      }
    }
  }
}
vector<int> path;
int from[maxn * maxn * 2], to[maxn * maxn * 2], val[maxn * maxn * 2], sz;
inline void add(int f, int t, int v) {
  from[sz] = f, to[sz] = t, val[sz] = v, sz++;
}
inline void push(int source, int target, int value) {
  if (source == target) return;
  int pr = pre[target];
  int VAL = min(a[pr], value);
  a[pr] -= VAL, a[target] += VAL;
  add(pr, target, VAL);
  push(source, pr, value);
  a[pr] -= value - VAL;
  a[target] += value - VAL;
  if (value - VAL) add(pr, target, value - VAL);
}
int32_t main() {
  int n = in(), v = in(), e = in();
  read(a, n);
  read(b, n);
  for (int i = 0; i < e; i++) {
    int v = in() - 1, u = in() - 1;
    g[v].push_back(u), g[u].push_back(v);
  }
  for (int v = 0; v < n; v++) {
    if (a[v] <= b[v]) continue;
    bfs(v);
    for (int u = 0; u < n; u++) {
      if (di[u] >= inf) continue;
      if (a[u] >= b[u]) continue;
      int val = min(a[v] - b[v], b[u] - a[u]);
      if (val == 0) break;
      push(v, u, val);
    }
  }
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) out("NO\n");
  cout << sz << "\n";
  for (int i = 0; i < sz; i++) {
    printf("%d %d %d\n", from[i] + 1, to[i] + 1, val[i]);
  }
}