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>
int a[300], b[300];
int nd[2 * 50000], nxt[2 * 50000], ut[300], dr;
int r, rx[2 * 300 * 300], ry[2 * 300 * 300], rc[2 * 300 * 300];
int c[300], dc, ca[300], da, cb[300], db;
char fol[300], fol2[300];
int v;
void comp(int x) {
  fol[x] = 1;
  c[dc++] = x;
  int p = ut[x];
  while (p != -1) {
    if (!fol[nd[p]]) comp(nd[p]);
    p = nxt[p];
  }
}
inline int min2(int x, int y) { return x < y ? x : y; }
inline char impart() {
  int i;
  long long d = 0;
  da = db = 0;
  for (i = 0; i < dc; i++) {
    if (a[c[i]] > b[c[i]]) {
      ca[da++] = c[i];
    }
    if (a[c[i]] < b[c[i]]) {
      cb[db++] = c[i];
    }
    d += a[c[i]] - b[c[i]];
  }
  if (d == 0) return 1;
  return 0;
}
inline void add(int x, int y) {
  nd[dr] = y;
  nxt[dr] = ut[x];
  ut[x] = dr;
  dr++;
}
char mve(int x, int y, int d) {
  if (x == y) return 1;
  fol2[x] = 1;
  int p = ut[x], aux;
  char g = 0;
  while (p != -1 && !g) {
    if (!fol2[nd[p]]) {
      rx[r] = x;
      ry[r] = nd[p];
      aux = min2(d, v - a[nd[p]]);
      rc[r] = aux;
      a[x] -= rc[r];
      a[nd[p]] += rc[r];
      r++;
      g = mve(nd[p], y, d);
      if (!g) {
        r--;
        a[nd[p]] -= rc[r];
        a[x] += rc[r];
      } else {
        if (aux < d) {
          rx[r] = x;
          ry[r] = nd[p];
          rc[r] = d - aux;
          a[x] -= rc[r];
          a[nd[p]] += rc[r];
          r++;
        }
      }
    }
    p = nxt[p];
  }
  fol2[x] = 0;
  return g;
}
int main() {
  int n, e, i, x, y, d, ma, mb;
  scanf("%d%d%d", &n, &v, &e);
  memset(ut, -1, sizeof ut);
  for (i = 0; i < n; i++) scanf("%d", &a[i]);
  for (i = 0; i < n; i++) scanf("%d", &b[i]);
  for (i = 0; i < e; i++) {
    scanf("%d%d", &x, &y);
    x--;
    y--;
    add(x, y);
    add(y, x);
  }
  for (i = 0; i < n; i++) {
    dc = 0;
    if (!fol[i]) {
      comp(i);
      if (!impart()) {
        printf("NO\n");
        return 0;
      } else {
        while (da > 0) {
          ma = a[ca[da - 1]] - b[ca[da - 1]];
          mb = b[cb[db - 1]] - a[cb[db - 1]];
          if (ma < mb) {
            mve(ca[da - 1], cb[db - 1], ma);
            da--;
          } else {
            mve(ca[da - 1], cb[db - 1], mb);
            db--;
            if (ma == mb) da--;
          }
        }
      }
    }
  }
  printf("%d\n", r);
  for (i = 0; i < r; i++) {
    printf("%d %d %d\n", rx[i] + 1, ry[i] + 1, rc[i]);
  }
  return 0;
}