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;
const int N = 400;
bool arr[N][N];
int pre[N][N], n, e;
long long a[N], b[N], c[N], v;
int top;
struct data {
  int s, t;
  long long d;
} ans[N * N * 2];
void floyd() {
  for (int k = 1; k <= n; k++) {
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (arr[i][j]) continue;
        if (arr[i][k] && arr[k][j]) {
          arr[i][j] = true;
          pre[i][j] = k;
        }
      }
    }
  }
}
void findpath(int s, int t, int q[], int &len) {
  if (pre[s][t] == s) {
    q[len++] = t;
    return;
  } else {
    findpath(pre[s][t], t, q, len);
    findpath(s, pre[s][t], q, len);
  }
}
void dfs(int index, int q[], int len, long long d) {
  if (index + 1 == len) return;
  long long tp;
  int s = q[index], t = q[index + 1];
  if (d + a[t] > v) {
    ans[top].s = s;
    ans[top].t = t;
    tp = ans[top].d = v - a[t];
    if (tp != 0) top++;
    a[t] = v;
    a[s] -= tp;
    dfs(index + 1, q, len, d);
    ans[top].s = s;
    ans[top].t = t;
    ans[top].d = d - tp;
    if (ans[top].d != 0) top++;
    a[s] = a[s] - d + tp;
    a[t] = a[t] + d - tp;
  } else {
    ans[top].s = s;
    ans[top].t = t;
    ans[top].d = d;
    if (d != 0) top++;
    a[t] += d;
    a[s] -= d;
    dfs(index + 1, q, len, d);
  }
}
int main() {
  while (scanf("%d%I64d%d", &n, &v, &e) != EOF) {
    memset(arr, false, sizeof(arr));
    memset(pre, -1, sizeof(pre));
    long long sum = 0;
    for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
    for (int i = 1; i <= n; i++) {
      scanf("%I64d", &b[i]);
      c[i] = a[i] - b[i];
      sum += c[i];
    }
    for (int i = 0, x, y; i < e; i++) {
      scanf("%d%d", &x, &y);
      arr[x][y] = arr[y][x] = true;
      pre[x][y] = x;
      pre[y][x] = y;
    }
    if (sum != 0) {
      printf("NO\n");
      continue;
    }
    floyd();
    top = 0;
    bool flag = true;
    for (int i = 1; i <= n; i++) {
      if (c[i] <= 0) continue;
      for (int j = 1; j <= n; j++) {
        if (c[j] >= 0 || !arr[i][j]) continue;
        long long tp = min(c[i], -c[j]);
        int path[N], len = 0;
        findpath(i, j, path, len);
        path[len++] = i;
        reverse(path, path + len);
        dfs(0, path, len, tp);
        c[i] -= tp;
        c[j] += tp;
      }
      if (c[i] > 0) {
        flag = false;
        break;
      }
    }
    if (flag) {
      printf("%d\n", top);
      for (int i = 0; i < top; i++)
        printf("%d %d %I64d\n", ans[i].s, ans[i].t, ans[i].d);
    } else {
      printf("NO\n");
    }
  }
  return 0;
}