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, v, e, i, j, k, g[302][302], rec[302][302], t1, t2, a[302], b[302], x, y,
    q[302], flow, c[302], len, mins, anslen, ans[200000][4];
bool p[302], p1;
long long sa, sb;
bool ff() {
  for (int i = 1; i <= n; i++)
    if (a[i] != b[i]) return 1;
  return 0;
}
int main() {
  scanf("%d%d%d", &n, &v, &e);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (i == j)
        g[i][j] = 0, rec[i][j] = 0;
      else
        g[i][j] = 1000;
  while (e--) {
    scanf("%d%d", &x, &y);
    g[x][y] = 1;
    g[y][x] = 1;
  }
  for (k = 1; k <= n; k++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        if (g[i][k] + g[k][j] < g[i][j]) g[i][j] = g[i][k] + g[k][j];
  for (k = 1; k <= n; k++)
    for (i = 1; i <= n; i++)
      for (j = 1; j <= n; j++)
        if ((g[i][k] == 1) && (g[k][j] + 1 == g[i][j])) rec[i][j] = k;
  for (i = 1; i <= n; i++) p[i] = 1;
  for (i = 1; i <= n; i++)
    if (p[i]) {
      sa = sb = 0;
      for (j = 1; j <= n; j++)
        if (g[i][j] < 1000) {
          sa += (long long)a[j];
          sb += (long long)b[j];
          p[j] = 0;
        }
      if (sa != sb) {
        cout << "NO" << endl;
        return 0;
      }
    }
  while (ff()) {
    p1 = 0;
    for (i = 1; i <= n; i++) {
      for (j = 1; j <= n; j++)
        if ((i != j) && (g[i][j] < 1000) && (a[i] > b[i]) && (b[j] > a[j])) {
          p1 = 1;
          break;
        }
      if (p1) break;
    }
    mins = min(a[i] - b[i], b[j] - a[j]);
    t1 = i;
    t2 = j;
    len = 1;
    q[1] = t1;
    x = t1;
    while (rec[x][t2]) {
      x = rec[x][t2];
      q[++len] = x;
    }
    for (i = 2; i < len; i++) c[q[i]] = a[q[i]];
    c[t1] = a[t1] - mins;
    c[t2] = a[t2] + mins;
    for (i = 1; i <= len - 1; i++) {
      flow = min(mins, v - a[q[i + 1]]);
      if (flow) {
        ans[++anslen][1] = q[i];
        ans[anslen][2] = q[i + 1];
        ans[anslen][3] = flow;
      }
      a[q[i]] -= flow;
      a[q[i + 1]] += flow;
    }
    for (i = len; i > 1; i--)
      if (a[q[i]] > c[q[i]]) {
        ans[++anslen][1] = q[i];
        ans[anslen][2] = q[i - 1];
        ans[anslen][3] = a[q[i]] - c[q[i]];
        a[q[i - 1]] += (a[q[i]] - c[q[i]]);
        a[q[i]] = c[q[i]];
      } else if (a[q[i]] < c[q[i]]) {
        ans[++anslen][1] = q[i - 1];
        ans[anslen][2] = q[i];
        ans[anslen][3] = c[q[i]] - a[q[i]];
        a[q[i - 1]] -= (c[q[i]] - a[q[i]]);
        a[q[i]] = c[q[i]];
      }
  }
  printf("%d\n", anslen);
  for (i = 1; i <= anslen; i++)
    printf("%d %d %d\n", ans[i][1], ans[i][2], ans[i][3]);
  return 0;
}