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 MAXN = 305;
struct Edge {
  int num, next;
  bool avai;
} e[MAXN * 5];
int en = 0, start[MAXN];
int d[MAXN];
inline void Add_edge(int p, int q) {
  en++;
  e[en].num = q;
  e[en].next = start[p];
  start[p] = en;
  d[p]++;
  e[en].avai = true;
  en++;
  e[en].num = p;
  e[en].next = start[q];
  start[q] = en;
  d[q]++;
  e[en].avai = true;
}
int fa[MAXN];
int getfa(int p) {
  if (p == fa[p]) return p;
  return fa[p] = getfa(fa[p]);
}
long long s[MAXN];
int n, v;
int a[MAXN], b[MAXN];
int ans[1000000][3], top = 0;
bool u[MAXN];
int best[MAXN];
int po, amo;
void dfs1(int p) {
  u[p] = true;
  for (int i = start[p]; i != 0; i = e[i].next)
    if (e[i].avai && !u[e[i].num]) {
      best[e[i].num] = min(v - a[p], best[p]);
      fa[e[i].num] = p;
      if (min(a[e[i].num], best[e[i].num]) > amo) {
        amo = min(a[e[i].num], best[e[i].num]);
        po = e[i].num;
      }
      dfs1(e[i].num);
    }
}
void dfs2(int p) {
  u[p] = true;
  for (int i = start[p]; i != 0; i = e[i].next)
    if (e[i].avai && !u[e[i].num]) {
      best[e[i].num] = min(a[p], best[p]);
      fa[e[i].num] = p;
      if (min(v - a[e[i].num], best[e[i].num]) > amo) {
        amo = min(v - a[e[i].num], best[e[i].num]);
        po = e[i].num;
      }
      dfs2(e[i].num);
    }
}
void work(int p) {
  if (a[p] == b[p]) return;
  for (int t = 1;; t++) {
    if (a[p] == b[p]) return;
    memset(u, 0, sizeof(u));
    memset(best, 60, sizeof(best));
    memset(fa, 0, sizeof(fa));
    amo = 0;
    if (a[p] < b[p]) {
      dfs1(p);
      if (amo > b[p] - a[p]) amo = b[p] - a[p];
      while (po != p) {
        top++;
        ans[top][0] = po;
        ans[top][1] = fa[po];
        ans[top][2] = amo;
        a[po] -= amo;
        a[fa[po]] += amo;
        po = fa[po];
      }
    } else {
      dfs2(p);
      if (amo > a[p] - b[p]) amo = a[p] - b[p];
      while (po != p) {
        top++;
        ans[top][1] = po;
        ans[top][0] = fa[po];
        ans[top][2] = amo;
        a[po] += amo;
        a[fa[po]] -= amo;
        po = fa[po];
      }
    }
  }
}
int main() {
  int t;
  scanf("%d%d%d", &n, &v, &t);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
  for (int i = 1; i <= n; i++) fa[i] = i;
  while (t--) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (getfa(x) != getfa(y)) {
      Add_edge(x, y);
      fa[getfa(x)] = getfa(y);
    }
  }
  for (int i = 1; i <= n; i++) s[getfa(i)] += a[i] - b[i];
  for (int i = 1; i <= n; i++)
    if (s[i] != 0) {
      printf("NO\n");
      return 0;
    }
  bool f = true;
  while (f) {
    f = false;
    for (int i = 1; i <= n; i++)
      if (d[i] == 1) {
        work(i);
        for (int j = start[i]; j != 0; j = e[j].next)
          if (e[j].avai) {
            int nm = ((j - 1) ^ 1) + 1;
            e[nm].avai = false;
            e[j].avai = false;
            d[i]--;
            d[e[j].num]--;
            break;
          }
        f = true;
        break;
      }
  }
  printf("%d\n", top);
  for (int i = 1; i <= top; i++)
    printf("%d %d %d\n", ans[i][0], ans[i][1], ans[i][2]);
  return 0;
}