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;
using ll = long long;
using ld = long double;
template <class T>
bool ckmin(T& a, const T& b) {
  return a > b ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 300 + 10;
vector<int> g[N], h[N];
ll a[N], b[N], val, sum, p[N], deg[N];
bool vis[N], vis1[N], dead[N];
vector<int> cmp;
void dfs_init(int u) {
  vis1[u] = 1;
  sum += a[u] - b[u];
  cmp.push_back(u);
  for (int v : g[u]) {
    if (vis1[v]) continue;
    p[v] = u;
    ++deg[u];
    dfs_init(v);
  }
}
vector<tuple<int, int, int>> op;
void do_op(int u, int v, int d) {
  a[u] -= d;
  a[v] += d;
  op.emplace_back(u, v, d);
}
void fill_up(int u) {
  vis[u] = 1;
  for (int v : g[u]) {
    if (vis[v] || dead[v]) continue;
    fill_up(v);
    if (a[u] + a[v] <= val)
      do_op(v, u, a[v]);
    else
      do_op(v, u, val - a[u]);
  }
}
void empty_it(int u) {
  vis[u] = 1;
  for (int v : g[u]) {
    if (vis[v] || dead[v]) continue;
    empty_it(v);
    if (a[u] + a[v] <= val)
      do_op(u, v, a[u]);
    else
      do_op(u, v, val - a[v]);
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> val >> m;
  for (auto i = (0); i < (n); ++i) cin >> a[i];
  for (auto i = (0); i < (n); ++i) cin >> b[i];
  for (auto e = (0); e < (m); ++e) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (auto u = (0); u < (n); ++u) {
    if (vis1[u]) continue;
    sum = 0;
    cmp.clear();
    p[u] = -1;
    dfs_init(u);
    if (sum != 0) return cout << "NO", 0;
    queue<int> q;
    for (auto x : cmp)
      if (deg[x] == 0) q.push(x);
    while (!q.empty()) {
      auto v = q.front();
      q.pop();
      assert(!dead[v]);
      dead[v] = 1;
      if (p[v] != -1 && --deg[p[v]] == 0) q.push(p[v]);
      if (a[v] == b[v]) continue;
      assert(p[v] != -1);
      fill_n(vis, n, 0);
      if (a[v] < b[v]) {
        fill_up(p[v]);
        do_op(p[v], v, b[v] - a[v]);
      } else {
        empty_it(p[v]);
        do_op(v, p[v], a[v] - b[v]);
      }
    }
  }
  cout << int((op).size()) << '\n';
  for (auto [x, y, d] : op) cout << x + 1 << ' ' << y + 1 << ' ' << d << '\n';
}