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;
pair<int, int> operator+(const pair<int, int> &a, const pair<int, int> &b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
pair<int, int> operator-(const pair<int, int> &a, const pair<int, int> &b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
pair<int, int> &operator+=(pair<int, int> &a, const pair<int, int> &b) {
  a.first += b.first;
  a.second += b.second;
  return a;
}
pair<int, int> &operator-=(pair<int, int> &a, const pair<int, int> &b) {
  a.first -= b.first;
  a.second -= b.second;
  return a;
}
template <class T, class U>
bool cmp_second(const pair<T, U> &a, const pair<T, U> &b) {
  return a.second < b.second;
}
template <class T>
T gcd(T a, T b) {
  a = abs(a);
  b = abs(b);
  while (b) {
    T t = b;
    b = a % b;
    a = t;
  }
  return a;
}
template <class T>
pair<T, T> ext_gcd(T a, T b) {
  T a0 = 1, a1 = 0, b0 = 0, b1 = 1;
  if (a < 0) {
    a = -a;
    a0 = -1;
  }
  if (b < 0) {
    b = -b;
    b1 = -1;
  }
  while (b) {
    T t, q = a / b;
    t = b;
    b = a - b * q;
    a = t;
    t = b0;
    b0 = a0 - b0 * q;
    a0 = t;
    t = b1;
    b1 = a1 - b1 * q;
    a1 = t;
  }
  return make_pair(a0, a1);
}
inline int sg(int x) { return x ? (x > 0 ? 1 : -1) : 0; }
class DisjointSet {
 public:
  int n;
  int *rep, *rank;
  DisjointSet(int _n) : n(_n) {
    rep = new int[n];
    rank = new int[n];
    for (int i = 0; i < n; i++) rep[i] = i;
  }
  ~DisjointSet() {
    delete[] rep;
    delete[] rank;
  }
  int getrep(int v) {
    if (rep[v] != v) rep[v] = getrep(rep[v]);
    return rep[v];
  }
  bool merge(int v, int u) {
    v = getrep(v);
    u = getrep(u);
    if (v == u) return 0;
    if (rank[v] < rank[u]) {
      rep[v] = u;
    } else {
      rep[u] = v;
      if (rank[v] == rank[u]) rank[v]++;
    }
    return 1;
  }
};
int n, cap, ne;
int cur[330], goal[330];
vector<int> adj[330];
vector<int> order;
vector<pair<pair<int, int>, int> > seq;
bool vis[330], inactive[330];
void dfs(int v) {
  vis[v] = 1;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (vis[u]) continue;
    dfs(u);
  }
  order.push_back(v);
}
int suck(int v, int req, int p, bool fixed) {
  vis[v] = 1;
  int ret = 0;
  if (!fixed) {
    int a = min(cur[v], req);
    ret += a;
    cur[v] -= a;
    req -= a;
  }
  for (int i = 0; req && i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (vis[u]) continue;
    if (inactive[u]) continue;
    int uret = suck(u, req, v, 0);
    ret += uret;
    req -= uret;
  }
  if (!fixed) seq.push_back(make_pair(make_pair(v, p), ret));
  return ret;
}
int push(int v, int req, int p, bool fixed) {
  vis[v] = 1;
  int ret = 0;
  if (!fixed) {
    int a = min(cap - cur[v], req);
    ret += a;
    cur[v] += a;
    req -= a;
  }
  for (int i = 0; req && i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (vis[u]) continue;
    if (inactive[u]) continue;
    int uret = push(u, req, v, 0);
    ret += uret;
    req -= uret;
    seq.push_back(make_pair(make_pair(v, u), uret));
  }
  return ret;
}
bool solve() {
  for (int v = 1; v <= n; v++)
    if (!vis[v]) dfs(v);
  for (int o = 0; o < n; o++) {
    int v = order[o];
    memset(vis, 0, sizeof(vis));
    if (cur[v] > goal[v]) {
      int amt = cur[v] - goal[v];
      int ret = push(v, amt, -1, 1);
      if (ret != amt) return 0;
    } else if (cur[v] < goal[v]) {
      int amt = goal[v] - cur[v];
      int ret = suck(v, amt, -1, 1);
      if (ret != amt) return 0;
    }
    inactive[v] = 1;
  }
  printf("%d\n", (int)seq.size());
  for (int i = 0; i < seq.size(); i++)
    printf("%d %d %d\n", seq[i].first.first, seq[i].first.second,
           seq[i].second);
  ;
  return 1;
}
int main(void) {
  scanf("%d %d %d", &(n), &(cap), &(ne));
  DisjointSet djs(n + 1);
  for (int i = 1; i <= n; i++) scanf("%d", &(cur[i]));
  for (int i = 1; i <= n; i++) scanf("%d", &(goal[i]));
  for (int i = 0; i < ne; i++) {
    int v, u;
    scanf("%d %d", &(v), &(u));
    if (djs.getrep(v) == djs.getrep(u)) continue;
    djs.merge(v, u);
    adj[v].push_back(u);
    adj[u].push_back(v);
  }
  if (!solve()) puts("NO");
  return 0;
}