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 long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = 3.1415926535897932384626433832795;
template <class T>
T sqr(T x) {
  return x * x;
}
template <class T>
T abs(T x) {
  return x < 0 ? -x : x;
}
const int nmax = 350;
int n, R, e;
int bufa[nmax];
int a[nmax], b[nmax], used[nmax];
vector<pair<int, int> > w;
vector<int> g[nmax];
int p[nmax], pr[nmax];
vector<pair<pair<int, int>, int> > res;
long long sa[nmax], sb[nmax];
void write() {
  cout << res.size() << endl;
  for (int i = 0; i < (int)(res.size()); i++)
    printf("%d %d %d\n", res[i].first.first + 1, res[i].first.second + 1,
           res[i].second);
  exit(0);
}
int get(int v) {
  if (p[v] == v) return v;
  return p[v] = get(p[v]);
}
void merge(int v, int u) {
  v = get(v);
  u = get(u);
  if (rand() & 1)
    p[v] = u;
  else
    p[u] = v;
}
void add(int x, int y) { w.push_back(make_pair(x, y)); }
void gen() {
  for (int i = 0; i < (int)(n); i++) p[i] = i;
  random_shuffle(w.begin(), w.end());
  for (int i = 0; i < (int)(w.size()); i++) {
    int v = w[i].first;
    int u = w[i].second;
    if (get(v) == get(u)) continue;
    g[v].push_back(u);
    g[u].push_back(v);
    merge(v, u);
  }
}
void no() {
  puts("NO");
  exit(0);
}
void dfs(int v, int p) {
  pr[v] = p;
  used[v] = 1;
  sa[v] = a[v];
  sb[v] = b[v];
  for (int i = 0; i < (int)(g[v].size()); i++) {
    int u = g[v][i];
    if (!used[u]) {
      dfs(u, v);
      sa[v] += sa[u];
      sb[v] += sb[u];
    }
  }
}
long long calc(int v, int u) {
  if (sa[v] > sb[v]) {
    long long res = min(a[v], R - a[u]);
    res = min(res, sa[v] - sb[v]);
    return max(res, 0ll);
  } else {
    long long res = min(a[u], R - a[v]);
    res = min(res, sb[v] - sa[v]);
    return max(res, 0ll);
  }
}
void move(int v, int u, int cn) {
  if (sa[v] > sb[v]) {
    sa[v] -= cn;
    a[v] -= cn;
    a[u] += cn;
    res.push_back(make_pair(make_pair(v, u), cn));
  } else {
    sa[v] += cn;
    a[v] += cn;
    a[u] -= cn;
    res.push_back(make_pair(make_pair(u, v), cn));
  }
}
void do_solve() {
  memset(used, 0, sizeof used);
  vector<int> qwe;
  for (int i = 0; i < (int)(n); i++) qwe.push_back(i);
  random_shuffle(qwe.begin(), qwe.end());
  for (int i = 0; i < (int)(n); i++)
    if (!used[qwe[i]]) dfs(qwe[i], -1);
  res.clear();
  while (1) {
    pair<int, int> pos = make_pair(-1, -1);
    int cn = 0;
    for (int i = 0; i < (int)(n); i++)
      if (pr[i] != -1) {
        int now = calc(i, pr[i]);
        if (now > cn) {
          cn = now;
          pos = make_pair(i, pr[i]);
        }
      }
    if (cn == 0) break;
    move(pos.first, pos.second, cn);
    if (res.size() > 2 * n * n) return;
  }
  for (int i = 0; i < (int)(n); i++)
    if (a[i] != b[i]) no();
  if (res.size() > 2 * n * n) return;
  write();
}
void solve() {
  for (int i = 0; i < (int)(n); i++) bufa[i] = a[i];
  while (1) {
    for (int i = 0; i < (int)(n); i++) {
      a[i] = bufa[i];
      g[i].clear();
    }
    gen();
    do_solve();
  }
}
int main() {
  cin >> n >> R >> e;
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
  }
  for (int i = 0; i < (int)(n); i++) {
    cin >> b[i];
    p[i] = i;
  }
  for (int i = 0; i < (int)(e); i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    x--;
    y--;
    add(x, y);
  }
  solve();
  return 0;
}