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 szs1[400];
int szs2[400];
int numa;
int numd;
int numb;
int vmax;
int totb;
int top1;
int top2;
long long int sum;
struct nodea {
  int w1;
  int w2;
  int v;
};
nodea sza[180100];
struct nodeb {
  int next;
  int v;
};
nodeb szb[50100 << 1];
struct noded {
  bool vis;
  int next;
  int deep;
  int ind;
  int fa;
  int v1;
  int v2;
  int getv() { return abs(v1 - v2); }
};
noded szd[400];
void adde(int from, int to) {
  totb++;
  szb[totb].v = to;
  szb[totb].next = szd[from].ind;
  szd[from].ind = totb;
  return;
}
void dfs(int x, int fa, int deep) {
  int f1;
  szd[x].vis = true;
  szd[x].fa = fa;
  szd[x].deep = deep;
  sum += szd[x].v1;
  sum -= szd[x].v2;
  if (szd[x].v1 > szd[x].v2) szs1[++top1] = x;
  if (szd[x].v1 < szd[x].v2) szs2[++top2] = x;
  for (f1 = szd[x].ind; f1 != 0; f1 = szb[f1].next)
    if ((szb[f1].v != fa) && (szd[szb[f1].v].vis == false))
      dfs(szb[f1].v, x, deep + 1);
  return;
}
void trans(int w1, int w2, int v) {
  if (w1 == w2) return;
  if (vmax - szd[szd[w1].next].v1 > v) {
    szd[w1].v1 -= v;
    szd[szd[w1].next].v1 += v;
    sza[++numa] = (nodea){w1, szd[w1].next, v};
    trans(szd[w1].next, w2, v);
  } else {
    trans(szd[w1].next, w2, v);
    szd[w1].v1 -= v;
    szd[szd[w1].next].v1 += v;
    sza[++numa] = (nodea){w1, szd[w1].next, v};
  }
  return;
}
void deal() {
  int vc;
  int f1;
  int f2;
  while ((top1 != 0) && (top2 != 0)) {
    f1 = szs1[top1];
    f2 = szs2[top2];
    for (; szd[f1].deep > szd[f2].deep; f1 = szd[f1].fa)
      szd[f1].next = szd[f1].fa;
    for (; szd[f1].deep < szd[f2].deep; f2 = szd[f2].fa)
      szd[szd[f2].fa].next = f2;
    for (; f1 != f2; f1 = szd[f1].fa, f2 = szd[f2].fa) {
      szd[f1].next = szd[f1].fa;
      szd[szd[f2].fa].next = f2;
    }
    vc = min(szd[szs1[top1]].getv(), szd[szs2[top2]].getv());
    if (vc <= (vmax >> 1))
      trans(szs1[top1], szs2[top2], vc);
    else {
      trans(szs1[top1], szs2[top2], vc >> 1);
      trans(szs1[top1], szs2[top2], vc - (vc >> 1));
    }
    if (szd[szs1[top1]].getv() == 0) top1--;
    if (szd[szs2[top2]].getv() == 0) top2--;
  }
  return;
}
int main() {
  int w1;
  int w2;
  int f1;
  scanf("%d%d%d", &numd, &vmax, &numb);
  for (f1 = 1; f1 <= numd; f1++) scanf("%d", &szd[f1].v1);
  for (f1 = 1; f1 <= numd; f1++) scanf("%d", &szd[f1].v2);
  for (f1 = 1; f1 <= numb; f1++) {
    scanf("%d%d", &w1, &w2);
    adde(w1, w2);
    adde(w2, w1);
  }
  for (f1 = 1; f1 <= numd; f1++)
    if (szd[f1].vis == false) {
      dfs(f1, 0, 1);
      if (sum != 0) break;
      deal();
    }
  if (f1 <= numd)
    printf("NO\n");
  else {
    printf("%d\n", numa);
    for (f1 = 1; f1 <= numa; f1++)
      printf("%d %d %d\n", sza[f1].w1, sza[f1].w2, sza[f1].v);
  }
  return 0;
}