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 n, p[307], sa[307], a[307], b[307], sb[307], ve, e, d[307], td;
vector<int> g[307], xa, ya, da;
bool u[307];
void ini(void) {
  for (int i = 0; i < 307; ++i) p[i] = i;
}
int get(int x) { return p[x] = x == p[x] ? x : get(p[x]); }
void uni(int x, int y) {
  x = get(x);
  y = get(y);
  p[y] = x;
  sa[x] += sa[y];
  sb[x] += sb[y];
}
void read(void) {
  cin >> n >> ve >> e;
  for (int i = 1; i <= n; ++i) cin >> a[i], sa[i] = a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i], sb[i] = b[i];
  ini();
  for (int i = 0, x, y; i < e; ++i) {
    cin >> x >> y;
    if (get(x) != get(y)) {
      uni(x, y);
      g[x].push_back(y);
      g[y].push_back(x);
      d[x]++;
      d[y]++;
    }
  }
}
bool pos(void) {
  for (int i = 1; i <= n; ++i)
    if (p[i] == i && sa[i] != sb[i]) return 0;
  return 1;
}
void dfs(int v) {
  u[v] = 1;
  for (int i = 0; i < (int)g[v].size(); ++i) {
    int to = g[v][i];
    if (u[to] || d[to] <= 0) continue;
    dfs(to);
    long long v1;
    if (td == v)
      v1 = b[v];
    else
      v1 = ve;
    long long d = min((v1 - a[v]), a[to]);
    a[v] += d;
    a[to] -= d;
    xa.push_back(to);
    ya.push_back(v);
    da.push_back(d);
  }
}
void mdfs(int v) {
  u[v] = 1;
  for (int i = 0; i < (int)g[v].size(); ++i) {
    int to = g[v][i];
    if (u[to] || d[to] <= 0) continue;
    mdfs(to);
    long long v1;
    if (td == v)
      v1 = b[v];
    else
      v1 = 0;
    long long d = min((a[v] - v1), (ve - a[to]));
    a[v] -= d;
    a[to] += d;
    ya.push_back(to);
    xa.push_back(v);
    da.push_back(d);
  }
}
void kill(void) {
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) u[j] = 0;
    for (int j = 1; j <= n; ++j)
      if (d[j] == 1) {
        td = j;
        if (a[j] <= b[j])
          dfs(j);
        else
          mdfs(j);
        d[j] = 0;
        for (int k = 0; k < (int)g[j].size(); ++k) {
          int to = g[j][k];
          if (d[to] >= 1) d[to]--;
        }
        break;
      }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  read();
  if (pos()) {
    kill();
    cout << xa.size() << "\n";
    for (int i = 0; i < (int)xa.size(); ++i)
      cout << xa[i] << " " << ya[i] << " " << da[i] << "\n";
  } else
    cout << "NO\n";
  return 0;
}