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>
#pragma comment(linker, "/STACK:1000000000,1000000000")
using namespace std;
const long long inf = 1e18 + 7;
const long long mod = 1e9 + 7;
const double eps = 1e-9;
const double PI = 2 * acos(0.0);
const double E = 2.71828;
struct output {
  long long from, to, val;
};
long long n, V, e, tot = 0;
long long a[305], b[305];
long long d[305][305], vis[305], used[305], h[305];
output ans[305 * 305 * 4];
long long size = 0;
long long q[305], sz = 0;
void add(long long from, long long to, long long val) {
  output now = {from + 1, to + 1, val};
  ans[size++] = now;
}
void dfs(long long v) {
  vis[v] = 1;
  tot += a[v] - b[v];
  for (long long(i) = 0; (i) < (long long)(n); (i)++)
    if (!vis[i] && d[v][i]) dfs(i), d[v][i] = d[i][v] = 2;
  q[sz++] = v;
}
void push(long long v, long long val) {
  h[v] = 1;
  for (long long(i) = 0; (i) < (long long)(n); (i)++) {
    if (!val) break;
    if (!h[i] && !used[i] && d[v][i] == 2) {
      if (V - a[i] >= val) {
        add(v, i, val);
        a[i] += val;
        a[v] -= val;
        val = 0;
      } else {
        push(i, val - (V - a[i]));
        long long now = min(val, V - a[i]);
        add(v, i, now);
        a[i] += now;
        a[v] -= now;
        val -= now;
      }
    }
  }
}
void pull(long long v, long long val) {
  h[v] = 1;
  for (long long(i) = 0; (i) < (long long)(n); (i)++) {
    if (!val) break;
    if (!h[i] && !used[i] && d[v][i] == 2) {
      if (a[i] >= val) {
        add(i, v, val);
        a[i] -= val;
        a[v] += val;
        val = 0;
      } else {
        pull(i, val - a[i]);
        long long now = min(val, a[i]);
        add(i, v, now);
        a[v] += now;
        a[i] -= now;
        val -= now;
      }
    }
  }
}
int main(void) {
  cin >> n >> V >> e;
  for (long long(i) = 0; (i) < (long long)(n); (i)++) scanf("%I64d", &a[i]);
  for (long long(i) = 0; (i) < (long long)(n); (i)++) scanf("%I64d", &b[i]);
  for (long long(i) = 0; (i) < (long long)(e); (i)++) {
    int x, y;
    scanf("%d%d", &x, &y);
    x--;
    y--;
    d[x][y] = d[y][x] = 1;
  }
  for (long long(i) = 0; (i) < (long long)(n); (i)++)
    if (!vis[i]) {
      tot = sz = 0;
      dfs(i);
      if (tot) cout << "NO" << endl, exit(0);
      for (long long(j) = 0; (j) < (long long)(sz); (j)++) {
        long long now = q[j];
        memset(h, 0, sizeof(h));
        if (a[now] > b[now]) push(now, a[now] - b[now]);
        if (a[now] < b[now]) pull(now, b[now] - a[now]);
        used[now] = 1;
      }
    }
  printf("%d\n", int(size));
  for (long long(i) = 0; (i) < (long long)(size); (i)++) {
    printf("%d %d %d\n", (int)ans[i].from, (int)ans[i].to, (int)ans[i].val);
  }
  return 0;
}