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 MAXN = 310, MAXM = 50000 + 10;
vector<pair<pair<int, int>, int> > CC;
struct Graph {
  int id, next;
} g[MAXN * 2];
int n, m, st[MAXN], a[MAXN], b[MAXN], v, f[MAXN], tot, cnt[MAXN];
pair<int, int> e[MAXM];
int getf(int first) {
  if (f[first] == first) return first;
  f[first] = getf(f[first]);
  return f[first];
}
bool Union(int first, int second) {
  int fx = getf(first), fy = getf(second);
  if (fx == fy) return false;
  f[fx] = fy;
  return true;
}
void Add(int first, int second) {
  g[tot].id = second, g[tot].next = st[first], st[first] = tot++;
  g[tot].id = first, g[tot].next = st[second], st[second] = tot++;
}
void init() {
  scanf("%d%d%d", &n, &v, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int j = 1; j <= n; ++j) scanf("%d", &b[j]);
  for (int i = 1; i <= n; ++i) f[i] = i;
  memset(st, -1, sizeof(st));
  for (int i = 1; i <= m; ++i) {
    int first, second;
    scanf("%d%d", &first, &second);
    e[i] = make_pair(first, second);
    if (Union(first, second)) Add(first, second);
  }
  for (int i = 1; i <= n; ++i) cnt[getf(i)] += a[i] - b[i];
  for (int i = 1; i <= n; ++i)
    if (cnt[i] != 0) puts("NO"), exit(0);
}
int fa[MAXN];
bool used[MAXN];
int Gain(int first, int fx, int res) {
  if (res == 0) return 0;
  if (res > 0 && a[first] >= res) {
    a[fx] += res, a[first] -= res;
    CC.push_back(make_pair(make_pair(first, fx), res));
    return -res;
  }
  if (res < 0 && v + res >= a[first]) {
    a[fx] += res, a[first] -= res;
    CC.push_back(make_pair(make_pair(fx, first), -res));
    return -res;
  }
  int flow = (res > 0) ? (res - a[first]) : ((v + res) - a[first]);
  for (int i = st[first]; i != -1; i = g[i].next)
    if (g[i].id != fx && !used[g[i].id]) {
      int F = Gain(g[i].id, first, flow);
      flow += F;
      if (flow == 0) break;
    }
  res -= flow;
  a[fx] += res, a[first] -= res;
  if (res + flow > 0) {
    if (res != 0) CC.push_back(make_pair(make_pair(first, fx), res));
  } else if (res != 0)
    CC.push_back(make_pair(make_pair(fx, first), -res));
  return -res;
}
void DFS(int first) {
  for (int i = st[first]; i != -1; i = g[i].next)
    if (g[i].id != fa[first]) fa[g[i].id] = first, DFS(g[i].id);
  used[first] = true;
  if (fa[first])
    Gain(fa[first], first, b[first] - a[first]);
  else if (a[first] != b[first])
    puts("NO"), exit(0);
}
void solve() {
  for (int i = 1; i <= n; ++i)
    if (!used[i]) DFS(i);
  cout << CC.size() << endl;
  for (int i = 0; i < (int)CC.size(); ++i)
    cout << CC[i].first.first << " " << CC[i].first.second << " "
         << CC[i].second << endl;
}
int main() {
  init();
  solve();
  fclose(stdin);
  fclose(stdout);
  return 0;
}