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;
struct dian {
  int id, de;
} di[310];
struct node {
  int next, to;
} e[1100];
struct move {
  int x, y, z;
} mv[100000];
int head[310], tot = 0, fa[310], vis[310], fat[310], fath[310], is[310],
               du[310];
int fp, rp, he, ta, q[310], lea[310], n, lim, m, top = 0;
int a[310], b[310];
long long c[310], d[310];
bool cmp(dian x, dian y) { return x.de > y.de; }
void add(int x, int y) {
  du[y]++;
  e[++tot].next = head[x];
  head[x] = tot;
  e[tot].to = y;
}
void addedge(int x, int y) {
  add(x, y);
  add(y, x);
}
int find(int x) {
  if (fa[x] != x) fa[x] = find(fa[x]);
  return fa[x];
}
void unionn(int x, int y) {
  int f1 = find(x), f2 = find(y);
  fa[f1] = f2;
}
void dfs(int x, int f) {
  int i, y;
  bool fl = 0;
  fat[x] = f;
  for (i = head[x]; i; i = e[i].next)
    if ((y = e[i].to) != f) {
      fl = 1;
      dfs(y, x);
    }
  if (!fl) lea[++rp] = x;
}
void dfs1(int x, int f, int dep) {
  int i, y;
  fath[x] = f;
  for (i = head[x]; i; i = e[i].next)
    if (((y = e[i].to) != f) && (!is[y])) {
      di[++ta].id = y;
      di[ta].de = dep;
      dfs1(y, x, dep + 1);
    }
}
void work(int x) {
  int i, y, fu, val;
  fp = 1;
  rp = 0;
  dfs(x, 0);
  while (fp <= rp) {
    ta = 0;
    dfs1(lea[fp], 0, 0);
    sort(di + 1, di + ta + 1, cmp);
    if (a[lea[fp]] < b[lea[fp]]) {
      for (i = 1; i <= ta; i++) {
        y = di[i].id;
        fu = fath[y];
        if (!fu) continue;
        val = min(lim - a[fu], a[y]);
        if (fu == lea[fp]) val = min(val, b[lea[fp]] - a[lea[fp]]);
        a[fu] += val;
        a[y] -= val;
        if (val) {
          mv[++top].x = y;
          mv[top].y = fu;
          mv[top].z = val;
        }
      }
    } else {
      for (i = 1; i <= ta; i++) {
        y = di[i].id;
        fu = fath[y];
        if (!fu) continue;
        val = min(lim - a[y], a[fu]);
        if (fu == lea[fp]) val = min(val, a[lea[fp]] - b[lea[fp]]);
        a[fu] -= val;
        a[y] += val;
        if (val) {
          mv[++top].x = fu;
          mv[top].y = y;
          mv[top].z = val;
        }
      }
    }
    du[fat[lea[fp]]]--;
    if ((du[fat[lea[fp]]] == 1) && (fat[lea[fp]] != x))
      lea[++rp] = fat[lea[fp]];
    is[lea[fp]] = 1;
    fp++;
  }
}
int main() {
  int i, j, x, y;
  scanf("%d%d%d", &n, &lim, &m);
  for (i = 1; i <= n; i++) fa[i] = i;
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (i = 1; i <= m; i++) {
    scanf("%d%d", &x, &y);
    if (find(x) != find(y)) {
      addedge(x, y);
      unionn(x, y);
    }
  }
  for (i = 1; i <= n; i++) {
    c[find(i)] += a[i];
    d[find(i)] += b[i];
  }
  for (i = 1; i <= n; i++)
    if (c[i] != d[i]) {
      printf("NO\n");
      return 0;
    }
  for (i = 1; i <= n; i++)
    if (!vis[find(i)]) {
      vis[find(i)] = 1;
      work(find(i));
    }
  printf("%d\n", top);
  for (i = 1; i <= top; i++) printf("%d %d %d\n", mv[i].x, mv[i].y, mv[i].z);
  return 0;
}