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;
int con[500][500], vst[500];
int a[500], b[500], dem[500];
int adj[500][500], deg[500];
int cur[500], tmp[500];
int id[500], cnt;
int pre[500], path[500], np;
int src[500 * 500 * 2], tar[500 * 500 * 2], sz[500 * 500 * 2], K;
queue<int> q;
bool cmp(int u, int v) { return dem[u] < dem[v]; }
void move(int s, int t, int m) {
  int i, u, v;
  if (m == 0) return;
  for (i = 0; i < cnt; i++) pre[id[i]] = -1;
  q.push(s);
  pre[s] = -2;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    for (i = 0; i < deg[u]; i++) {
      v = adj[u][i];
      if (pre[v] != -1) continue;
      pre[v] = u;
      q.push(v);
    }
  }
  np = 0;
  for (u = t; u != s; u = pre[u]) path[np++] = u;
  path[np++] = s;
  reverse(path, path + np);
  for (i = 0; i < np; i++) tmp[path[i]] = cur[path[i]];
  for (i = 0; i < np - 2; i++) {
    u = path[i];
    v = path[i + 1];
    if (tmp[v] >= m) continue;
    src[K] = u;
    tar[K] = v;
    sz[K] = m - tmp[v];
    K++;
    tmp[u] -= m - tmp[v];
    tmp[v] = m;
  }
  src[K] = path[np - 2];
  tar[K] = path[np - 1];
  sz[K] = m;
  K++;
  tmp[path[np - 2]] -= m;
  for (i = np - 1; i; i--) {
    u = path[i - 1];
    v = path[i];
    if (cur[v] == tmp[v]) continue;
    src[K] = u;
    tar[K] = v;
    sz[K] = cur[v] - tmp[v];
    K++;
    tmp[u] -= cur[v] - tmp[v];
  }
  cur[s] -= m;
  cur[t] += m;
  dem[s] += m;
  dem[t] -= m;
}
bool Solve() {
  int u, v, i, j, k;
  long long A, B;
  for (u = 0; u < N; u++) {
    deg[u] = 0;
    for (v = 0; v < N; v++)
      if (con[u][v]) adj[u][deg[u]++] = v;
  }
  K = 0;
  memset(vst, 0, sizeof(vst));
  for (i = 0; i < N; i++) {
    cur[i] = a[i];
    dem[i] = b[i] - a[i];
  }
  for (i = 0; i < N; i++) {
    if (vst[i]) continue;
    q.push(i);
    vst[i] = 1;
    cnt = 0;
    while (!q.empty()) {
      u = q.front();
      q.pop();
      id[cnt++] = u;
      for (j = 0; j < deg[u]; j++) {
        v = adj[u][j];
        if (vst[v]) continue;
        vst[v] = 1;
        q.push(v);
      }
    }
    A = B = 0;
    for (j = 0; j < cnt; j++) {
      u = id[j];
      A += a[u];
      B += b[u];
    }
    if (A != B) return false;
    sort(id, id + cnt, cmp);
    j = 0;
    k = cnt - 1;
    while (j < k) {
      if (dem[id[j]] + dem[id[k]] == 0) {
        move(id[j], id[k], dem[id[k]]);
        j++;
        k--;
      } else if (dem[id[j]] + dem[id[k]] < 0) {
        move(id[j], id[k], dem[id[k]]);
        k--;
      } else {
        move(id[j], id[k], -dem[id[j]]);
        j++;
      }
    }
  }
  return true;
}
int main() {
  int V, M, i, u, v;
  scanf("%d%d%d", &N, &V, &M);
  for (i = 0; i < N; i++) scanf("%d", &a[i]);
  for (i = 0; i < N; i++) scanf("%d", &b[i]);
  memset(con, 0, sizeof(con));
  for (i = 0; i < M; i++) {
    scanf("%d%d", &u, &v);
    u--, v--;
    con[u][v] = con[v][u] = 1;
  }
  if (Solve()) {
    printf("%d\n", K);
    for (i = 0; i < K; i++) printf("%d %d %d\n", src[i] + 1, tar[i] + 1, sz[i]);
  } else
    puts("NO");
  return 0;
}