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 N = 310, S = 301, T = 302, M = 51000;
struct Edge {
  int y, nex;
  long long z;
} g[M * 3];
int n, v, m, dis[N], sz = 1, pos[N], az, ax[M], ay[M], aw[M], que[N], hd, tl,
                     w[N], a[N], b[N], in[N];
long long sum, p1, p2;
void Init(int x, int y, long long z) {
  g[++sz].y = y;
  g[sz].nex = pos[x];
  g[sz].z = z;
  pos[x] = sz;
}
bool Bfs() {
  memset(dis, 0, sizeof(dis));
  que[hd = tl = 1] = S, dis[S] = 1;
  while (hd <= tl) {
    int x = que[hd++];
    for (int i = pos[x]; i; i = g[i].nex)
      if (g[i].z) {
        int y = g[i].y;
        if (!dis[y]) dis[y] = dis[x] + 1, que[++tl] = y;
      }
  }
  return dis[T];
}
long long Dfs(int x, long long mx) {
  if (x == T) return mx;
  long long ret = 0;
  for (int i = pos[x]; i; i = g[i].nex) {
    int y = g[i].y;
    long long k;
    if (mx && g[i].z && dis[y] == dis[x] + 1 && (k = Dfs(y, min(g[i].z, mx)))) {
      g[i].z -= k, g[i ^ 1].z += k, mx -= k, ret += k;
    }
  }
  if (mx) dis[x] = 0;
  return ret;
}
void Dinic() {
  long long ret = 0;
  while (Bfs()) {
    while (ret = Dfs(S, (1000000000000000LL))) sum += ret;
  }
}
bool Print() {
  for (int i = 1; i <= n; i++) in[i] = 0;
  for (int x = 1; x <= n; x++) {
    for (int i = pos[x]; i; i = g[i].nex)
      if (g[i].z < (1000000000000000LL)) in[g[i].y]++;
  }
  hd = 1, tl = 0;
  for (int i = 1; i <= n; i++)
    if (!in[i]) que[++tl] = i;
  if (tl == n) return 0;
  while (hd <= tl) {
    int x = que[hd++];
    for (int i = pos[x]; i; i = g[i].nex)
      if (g[i].y != T && g[i].y != S) {
        int y = g[i].y;
        long long z = min(((1000000000000000LL) - g[i].z),
                          (long long)min(v - w[y], w[x]));
        if (z > 0) {
          ax[++az] = x, ay[az] = y, aw[az] = z;
          w[y] += z, w[x] -= z, g[i].z += z;
        }
        in[y]--;
        if (!in[y]) que[++tl] = y;
      }
  }
  return 1;
}
int main() {
  scanf("%d%d%d", &n, &v, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]), w[i] = a[i];
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (a[i] > b[i])
      Init(S, i, a[i] - b[i]), Init(i, S, 0), p1 += a[i] - b[i];
    else
      Init(i, T, b[i] - a[i]), Init(T, i, 0), p2 += b[i] - a[i];
  }
  for (int i = 1; i <= m; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    Init(x, y, (1000000000000000LL)), Init(y, x, (1000000000000000LL));
  }
  Dinic();
  if (p1 != p2 || sum != p1) {
    puts("NO");
    return 0;
  }
  while (Print())
    ;
  printf("%d\n", az);
  for (int i = 1; i <= az; i++) printf("%d %d %d\n", ax[i], ay[i], aw[i]);
  return 0;
}