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, V, m, a[333], b[333];
long long sa, sb;
vector<int> e[333], g[333];
vector<pair<pair<int, int>, int> > res;
bool used[333], killed[333];
vector<int> order;
int pr[333];
int q[333], level[333], head, tail;
void dfs(int u) {
  used[u] = true;
  sa += a[u];
  sb += b[u];
  for (__typeof(e[u].begin()) it = e[u].begin(); it != e[u].end(); ++it) {
    int v = *it;
    if (!used[v]) {
      g[u].push_back(v);
      g[v].push_back(u);
      dfs(v);
    }
  }
  order.push_back(u);
}
void go(int u, int v, int x) {
  assert(x >= 0);
  if (x == 0) return;
  a[v] += x;
  a[u] -= x;
  res.push_back(make_pair(make_pair(u, v), x));
}
void doIt() {
  for (__typeof(order.begin()) it = order.begin(); it != order.end(); ++it) {
    int second = *it;
    memset(level, -1, sizeof(level));
    head = tail = 0;
    level[second] = 0;
    q[tail++] = second;
    while (head < tail) {
      int u = q[head++];
      for (__typeof(g[u].begin()) it = g[u].begin(); it != g[u].end(); ++it) {
        int v = *it;
        if (level[v] == -1 && !killed[v]) {
          level[v] = level[u] + 1;
          q[tail++] = v;
        }
      }
    }
    int need = b[second] - a[second];
    killed[second] = true;
    if (need == 0) continue;
    for (int i = tail - 1; i > 0; --i) {
      int u = q[i];
      for (__typeof(g[u].begin()) it = g[u].begin(); it != g[u].end(); ++it) {
        int v = *it;
        if (level[v] != level[u] - 1) continue;
        if (need > 0) {
          int x = min(a[u], V - a[v]);
          if (v == second) x = min(a[u], b[v] - a[v]);
          go(u, v, x);
        } else {
          int x = min(a[v], V - a[u]);
          if (v == second) x = min(a[v] - b[v], V - a[u]);
          go(v, u, x);
        }
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &V, &m);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i < n; ++i) scanf("%d", &b[i]);
  for (int i = 0; i < m; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x, --y;
    e[x].push_back(y);
    e[y].push_back(x);
  }
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      order.clear();
      sa = sb = 0;
      dfs(i);
      if (sa != sb) {
        puts("NO");
        return 0;
      }
      doIt();
    }
  }
  cout << res.size() << endl;
  for (int i = 0; i < res.size(); ++i)
    printf("%d %d %d\n", res[i].first.first + 1, res[i].first.second + 1,
           res[i].second);
  return 0;
}