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 INF = 1000000000;
const double EPS = 1e-9;
const int MAXN = 300;
int n, v, e;
int a[MAXN + 5], b[MAXN + 5], par[MAXN + 5], anak[MAXN + 5];
long long juma[MAXN + 5], jumb[MAXN + 5];
vector<int> adj[MAXN + 5], child[MAXN + 5];
bool udahdipop[MAXN + 5];
vector<pair<pair<int, int>, int> > ans;
void dfs(int p) {
  juma[p] = (long long)a[p];
  jumb[p] = (long long)b[p];
  for (int i = 0, _d = adj[p].size(); i < _d; i++)
    if (par[adj[p][i]] == -1) {
      anak[p]++;
      par[adj[p][i]] = p;
      child[p].push_back(adj[p][i]);
      dfs(adj[p][i]);
      juma[p] += juma[adj[p][i]];
      jumb[p] += jumb[adj[p][i]];
    }
}
void minta(int p, int q, int x) {
  if (a[p] >= x) {
    a[q] += x;
    a[p] -= x;
    ans.push_back(make_pair(make_pair(p, q), x));
    return;
  }
  if (par[p] != q && par[p] != 0 && !udahdipop[par[p]])
    minta(par[p], p, x - a[p]);
  for (int i = 0, _d = child[p].size(); i < _d; i++)
    if (child[p][i] != q && !udahdipop[child[p][i]]) {
      if (a[p] >= x) break;
      minta(child[p][i], p, x - a[p]);
    }
  if (a[p] < x) x = a[p];
  if (x) {
    a[q] += x;
    a[p] -= x;
    ans.push_back(make_pair(make_pair(p, q), x));
  }
}
void kirim(int p, int q, int x) {
  if (v >= a[p] + x) {
    a[q] -= x;
    a[p] += x;
    ans.push_back(make_pair(make_pair(q, p), x));
    return;
  }
  if (par[p] != q && par[p] != 0 && !udahdipop[par[p]])
    kirim(par[p], p, a[p] + x - v);
  for (int i = 0, _d = child[p].size(); i < _d; i++)
    if (child[p][i] != q && !udahdipop[child[p][i]]) {
      if (v >= a[p] + x) break;
      kirim(child[p][i], p, a[p] + x - v);
    }
  if (v < a[p] + x) x = v - a[p];
  if (x) {
    a[q] -= x;
    a[p] += x;
    ans.push_back(make_pair(make_pair(q, p), x));
  }
}
int main() {
  scanf("%d %d %d", &n, &v, &e);
  for (int i = 1, _d = n; i <= _d; i++) scanf("%d", &a[i]);
  for (int i = 1, _d = n; i <= _d; i++) scanf("%d", &b[i]);
  while (e--) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  memset(par, -1, sizeof(par));
  for (int i = 1, _d = n; i <= _d; i++)
    if (par[i] == -1) {
      par[i] = 0;
      dfs(i);
      if (juma[i] != jumb[i]) {
        printf("NO\n");
        return 0;
      }
    }
  queue<int> leaf;
  memset(udahdipop, 0, sizeof(udahdipop));
  for (int i = 1, _d = n; i <= _d; i++)
    if (!anak[i]) leaf.push(i);
  while (!leaf.empty()) {
    int p = leaf.front();
    leaf.pop();
    udahdipop[p] = 1;
    if (a[p] < b[p]) {
      minta(par[p], p, b[p] - a[p]);
    }
    if (a[p] > b[p]) {
      kirim(par[p], p, a[p] - b[p]);
    }
    anak[par[p]]--;
    if (!anak[par[p]]) leaf.push(par[p]);
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0, _d = (int)ans.size(); i < _d; i++)
    printf("%d %d %d\n", ans[i].first.first, ans[i].first.second,
           ans[i].second);
  return 0;
}