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 rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int maxn = 300;
vector<vector<int> > es;
int values[maxn][2];
int used[maxn], maxu;
vector<pair<pair<int, int>, int> > res;
int n, m, inside;
void addPush(int v1, int v2, int topush) {
  assert(topush >= 0);
  values[v1][0] -= topush, values[v2][0] += topush;
  assert(values[v1][0] >= 0 && values[v2][0] <= inside);
  res.push_back(make_pair(make_pair(v1, v2), topush));
}
void addPath(int* path, int cnt, int topush) {
  if (cnt == 1) return;
  assert(values[path[0]][0] >= topush);
  int toput = min(topush, inside - values[path[1]][0]);
  addPush(path[0], path[1], toput);
  addPath(path + 1, cnt - 1, topush);
  if (toput == topush) return;
  addPush(path[0], path[1], topush - toput);
}
int path[maxn];
int cntPath;
int pushed;
int dfs(int v, int topush) {
  path[cntPath++] = v;
  int can = 0;
  if (values[v][0] < values[v][1]) {
    can = min(values[v][1] - values[v][0], topush);
    addPath(path, cntPath, can);
    assert(++pushed <= n);
  }
  used[v] = maxu;
  for (int it = 0; can < topush && it < ((int)(es[v]).size()); ++it) {
    int u = es[v][it];
    if (used[u] == maxu) continue;
    can += dfs(u, topush - can);
  }
  cntPath--;
  return can;
}
bool solve() {
  if (scanf("%d%d%d", &n, &inside, &m) < 3) return 0;
  for (int j = 0; j < 2; ++j)
    for (int i = 0; i < n; ++i) scanf("%d", &values[i][j]);
  es = vector<vector<int> >(n);
  for (int i = 0; i < m; ++i) {
    int s, t;
    scanf("%d%d", &s, &t);
    --s, --t;
    es[s].push_back(t), es[t].push_back(s);
  }
  for (int i = 0; i < n; ++i) used[i] = 0;
  maxu = 0;
  pushed = 0;
  res.clear();
  bool fail = 0;
  for (int i = 0; i < n; ++i) {
    if (values[i][0] - values[i][1] > 0) {
      ++maxu;
      cntPath = 0;
      int want = values[i][0] - values[i][1];
      if (dfs(i, want) != want) {
        fail = 1;
        break;
      }
    }
  }
  for (int i = 0; !fail && i < n; ++i)
    if (values[i][0] != values[i][1]) fail = 1;
  if (fail) {
    printf("NO\n");
    return 1;
  }
  printf("%d\n", ((int)(res).size()));
  for (int i = 0; i < ((int)(res).size()); ++i)
    printf("%d %d %d\n", res[i].first.first + 1, res[i].first.second + 1,
           res[i].second);
  return 1;
}
int main() {
  srand(rdtsc());
  while (1) {
    if (!solve()) break;
  }
  return 0;
}