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 MAX_SIZE = 300;
struct Rec {
  int s, t, vol;
  Rec(int _s, int _t, int _vol) : s(_s), t(_t), vol(_vol) {}
  Rec() {}
};
int init[MAX_SIZE + 10], desi[MAX_SIZE + 10];
int nodes[MAX_SIZE + 10], fa[MAX_SIZE + 10], dep[MAX_SIZE + 10],
    to[MAX_SIZE * 2 + 10], nxt[MAX_SIZE * 2 + 10], en;
int father[MAX_SIZE + 10];
int n, m, lim;
bool vis[MAX_SIZE + 10];
int seq[MAX_SIZE + 10], sn;
long long size[MAX_SIZE + 10];
vector<Rec> ans;
int findFather(int a) {
  if (father[a] != a) father[a] = findFather(father[a]);
  return father[a];
}
inline void addEdge(int f, int t) {
  ++en;
  to[en] = t;
  nxt[en] = nodes[f];
  nodes[f] = en;
}
void dfs(int cur) {
  vis[cur] = true;
  seq[++sn] = cur;
  for (int e = nodes[cur]; e; e = nxt[e]) {
    if (!vis[to[e]]) {
      fa[to[e]] = cur;
      dep[to[e]] = dep[cur] + 1;
      dfs(to[e]);
    }
  }
}
inline int min(int a, int b) { return a < b ? a : b; }
int path[MAX_SIZE + 10], pn;
int A[MAX_SIZE + 10], an, B[MAX_SIZE + 10], bn;
void findPath(int s, int t) {
  an = bn = 0;
  while (s != t) {
    if (dep[s] > dep[t]) {
      A[++an] = s;
      s = fa[s];
    } else {
      B[++bn] = t;
      t = fa[t];
    }
  }
  A[++an] = s;
  for (int i = 1; i <= an; i++) path[i] = A[i];
  for (int i = 1; i <= bn; i++) path[an + bn - i + 1] = B[i];
  pn = an + bn;
}
void trans(int s, int t, int vol) {
  if (t == s + 1) {
    init[path[s]] -= vol;
    init[path[t]] += vol;
    ans.push_back(Rec(path[s], path[t], vol));
    return;
  }
  int tt = min(init[path[t - 1]], vol);
  init[path[t - 1]] -= tt;
  init[path[t]] += tt;
  ans.push_back(Rec(path[t - 1], path[t], tt));
  trans(s, t - 1, vol);
  init[path[t - 1]] -= vol - tt;
  init[path[t]] += vol - tt;
  ans.push_back(Rec(path[t - 1], path[t], vol - tt));
}
void work() {
  int p1 = 1, p2 = 1;
  while (p1 <= sn && desi[seq[p1]] >= init[seq[p1]]) ++p1;
  while (p2 <= sn && desi[seq[p2]] <= init[seq[p2]]) ++p2;
  while (p1 <= sn && p2 <= sn) {
    findPath(seq[p1], seq[p2]);
    trans(1, pn,
          min(init[seq[p1]] - desi[seq[p1]], desi[seq[p2]] - init[seq[p2]]));
    while (p1 <= sn && desi[seq[p1]] >= init[seq[p1]]) ++p1;
    while (p2 <= sn && desi[seq[p2]] <= init[seq[p2]]) ++p2;
  }
}
int main() {
  scanf("%d%d%d", &n, &lim, &m);
  for (int i = 1; i <= n; i++) scanf("%d", init + i);
  for (int i = 1; i <= n; i++) scanf("%d", desi + i);
  for (int i = 1; i <= n; i++) father[i] = i;
  for (int i = 1; i <= m; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    if (findFather(a) != findFather(b)) {
      father[findFather(a)] = findFather(b);
      addEdge(a, b);
      addEdge(b, a);
    }
  }
  for (int i = 1; i <= n; i++) size[findFather(i)] += desi[i] - init[i];
  for (int i = 1; i <= n; i++)
    if (size[i] != 0) {
      printf("NO\n");
      return 0;
    }
  for (int i = 1; i <= n; i++) {
    if (!vis[i]) {
      sn = 0;
      dfs(i);
      work();
    }
  }
  printf("%d\n", ans.size());
  for (vector<Rec>::iterator it = ans.begin(); it != ans.end(); it++)
    printf("%d %d %d\n", it->s, it->t, it->vol);
  return 0;
}