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 N = 400;
int n, v, e;
long long sum = 0;
int a[N + 1], s[N + 1], fa[N + 1], b[N + 1];
vector<int> nei[N + 1];
int getFather(int i) {
  if (fa[i] == -1) return i;
  return fa[i] = getFather(fa[i]);
}
bool vis[N + 1];
bool mark[N + 1];
int currentVo;
vector<pair<int, pair<int, int> > > ans;
void check(int cur, int p, int &x) {
  x = abs(currentVo);
  if (currentVo < 0) currentVo = min(0, currentVo + a[cur]);
  if (currentVo > 0) currentVo = max(currentVo - (v - a[cur]), 0);
  if (currentVo) x = -1;
  return;
}
bool isg = false;
void dfs2(int cur, int p) {
  int x = 0;
  if (!currentVo) return;
  if (cur != p) check(cur, p, x);
  for (int ne : nei[cur])
    if (ne != p && !mark[ne]) dfs2(ne, cur);
  if (cur == p) return;
  if (isg) {
    if (x == -1) x = min(v - a[cur], a[p]);
    a[cur] += x;
    a[p] -= x;
    ans.push_back(make_pair(x, make_pair(p, cur)));
  } else {
    if (x == -1) x = min(v - a[p], a[cur]);
    a[cur] -= x;
    a[p] += x;
    ans.push_back(make_pair(x, make_pair(cur, p)));
  }
  return;
}
void dfs(int cur, int p) {
  sum += s[cur];
  vis[cur] = true;
  for (int ne : nei[cur])
    if (ne != p) dfs(ne, cur);
  mark[cur] = true;
  currentVo = a[cur] - b[cur];
  isg = (currentVo > 0);
  if (currentVo) dfs2(cur, cur);
  return;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> v >> e;
  fill(fa, fa + N + 1, -1);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int j = 0; j < n; j++) cin >> b[j], s[j] = a[j] - b[j];
  for (int i = 0; i < e; i++) {
    int u, v;
    cin >> u >> v;
    u--, v--;
    int f = getFather(u);
    int ff = getFather(v);
    if (ff != f) {
      fa[ff] = f;
      nei[v].push_back(u);
      nei[u].push_back(v);
    }
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    sum = 0;
    dfs(i, i);
    if (sum != 0) return cout << "NO", 0;
  }
  cout << (int)ans.size() << endl;
  for (int i = 0; i < ans.size(); i++)
    cout << ans[i].second.first + 1 << ' ' << ans[i].second.second + 1 << ' '
         << ans[i].first << endl;
}