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;
int n, m, k;
int a[305], b[305];
int t[100005], nx[100005];
int t1, t2, te = 0;
int h[305];
int l[200005][5], p = 0, v[305];
int d[305][305];
int w1[305], w2[305], wd1 = 0, wd2 = 0;
void add() {
  te++;
  t[te] = t2, nx[te] = h[t1];
  h[t1] = te;
  return;
}
void s1_1(int x) {
  v[x] = -1;
  if (b[x] > a[x])
    w2[++wd2] = x;
  else if (b[x] < a[x])
    w1[++wd1] = x;
  for (int i = h[x]; i; i = nx[i]) {
    if (v[t[i]]) continue;
    s1_1(t[i]);
  }
  return;
}
int cnt = 0;
void s1_2(int x, int y) {
  v[y] = x;
  for (int i = h[y]; i; i = nx[i]) {
    if (d[x][y] == t[i] || t[i] == x || v[t[i]] == x) continue;
    d[x][t[i]] = y;
    s1_2(x, t[i]);
  }
  return;
}
void s2(int x, int y, int z) {
  if (x == y) return;
  int y2 = d[x][y];
  int z2 = min(z, a[y2]);
  a[y2] -= z2, a[y] += z2, p++;
  l[p][1] = y2, l[p][2] = y, l[p][3] = z2;
  s2(x, y2, z);
  if (z2 != z) {
    a[y2] -= (z - z2), a[y] += (z - z2), p++;
    l[p][1] = y2, l[p][2] = y, l[p][3] = (z - z2);
  }
  return;
}
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= m; i++) {
    scanf("%d%d", &t1, &t2);
    add();
    swap(t1, t2);
    add();
  }
  memset(v, 0, sizeof(v));
  memset(d, 0, sizeof(d));
  for (int i = 1; i <= n; i++) {
    if (v[i] == 0) {
      wd1 = wd2 = 0;
      s1_1(i);
      for (int j = 1; j <= wd1; j++) s1_2(w1[j], w1[j]);
      for (int j = 1; j <= wd2; j++) s1_2(w2[j], w2[j]);
      while (wd1 && wd2) {
        int p1 = w1[wd1], p2 = w2[wd2];
        if (a[p1] - b[p1] > b[p2] - a[p2]) {
          s2(p1, p2, b[p2] - a[p2]);
          wd2--;
        } else if (a[p1] - b[p1] < b[p2] - a[p2]) {
          s2(p1, p2, a[p1] - b[p1]);
          wd1--;
        } else {
          s2(p1, p2, a[p1] - b[p1]);
          wd1--, wd2--;
        }
      }
      if (wd1 || wd2) {
        puts("NO");
        return 0;
      }
    }
  }
  printf("%d\n", p);
  for (int i = 1; i <= p; i++) {
    if (i > 1) puts("");
    printf("%d %d %d", l[i][1], l[i][2], l[i][3]);
  }
  return 0;
}