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;
long long cap[350][350];
long long flw[350][350];
char vis[350];
long long maxcr;
int in[350], out[350];
int cnum;
int from[100000], to[100000];
long long mov[100000];
long long cur[350];
int n, e;
long long st, beg;
long long scnd;
int fulkerson(int u, long long cur) {
  if (u == n + 1) {
    st += cur;
    return cur;
  }
  vis[u] = 1;
  for (int v = n + 1; v >= 0; v--)
    if (vis[v] == 0)
      if (flw[u][v] < cap[u][v]) {
        long long code = fulkerson(v, min(cur, cap[u][v] - flw[u][v]));
        if (code > 0) {
          flw[u][v] += code;
          flw[v][u] -= code;
          return code;
        }
      }
  return 0;
}
void discharge(int u) {
  if (cur[u] == 0) return;
  for (int v = 1; v <= n; v++)
    if (flw[u][v] > 0) {
      if (cur[v] + min(flw[u][v], cur[u]) > maxcr) discharge(v);
      long long kre = min(flw[u][v], cur[u]);
      cnum++;
      from[cnum] = u;
      to[cnum] = v;
      mov[cnum] = kre;
      cur[u] -= kre;
      cur[v] += kre;
      flw[u][v] -= kre;
      if (flw[u][v] == 0) {
        in[v]--;
        out[u]--;
      }
      if (cur[u] == 0) break;
    }
}
int main() {
  scanf("%d", &n);
  cin >> maxcr;
  scanf("%d", &e);
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    cur[i] = x;
    cap[0][i] = x;
    beg += x;
  }
  for (int i = 1; i <= n; i++) {
    int x;
    scanf("%d", &x);
    cap[i][n + 1] = x;
    scnd += x;
  }
  if (beg != scnd) {
    printf("NO\n");
    return 0;
  }
  while (e--) {
    int x, y;
    scanf("%d%d", &x, &y);
    cap[x][y] = (1000000000000ll);
    cap[y][x] = (1000000000000ll);
  }
  while (fulkerson(0, (1000000000000ll))) {
    for (int i = 0; i <= n + 1; i++) vis[i] = 0;
  }
  if (beg != st) {
    printf("NO\n");
    return 0;
  }
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (flw[i][j] > 0) {
        in[j]++;
        out[i]++;
      }
  char ch = 1;
  while (ch) {
    ch = 0;
    for (int i = 1; i <= n; i++)
      if (out[i] > 0) {
        discharge(i);
        ch = 1;
      }
  }
  printf("%d\n", cnum);
  for (int i = 1; i <= cnum; i++)
    cout << from[i] << ' ' << to[i] << ' ' << mov[i] << '\n';
}