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 double PI = acos(-1);
const double eps = 1e-9;
const long long inf = 2000000000;
const long long infLL = 9000000000000000000;
inline bool checkBit(long long n, long long i) { return n & (1LL << i); }
inline long long setBit(long long n, long long i) {
  return n | (1LL << i);
  ;
}
inline long long resetBit(long long n, long long i) {
  return n & (~(1LL << i));
}
long long dx[] = {0, 0, +1, -1};
long long dy[] = {+1, -1, 0, 0};
inline bool EQ(double a, double b) { return fabs(a - b) < 1e-9; }
inline bool isLeapYear(long long year) {
  return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
}
inline void normal(long long &a) {
  a %= 1000000007;
  (a < 0) && (a += 1000000007);
}
inline long long modMul(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a * b) % 1000000007;
}
inline long long modAdd(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  return (a + b) % 1000000007;
}
inline long long modSub(long long a, long long b) {
  a %= 1000000007, b %= 1000000007;
  normal(a), normal(b);
  a -= b;
  normal(a);
  return a;
}
inline long long modPow(long long b, long long p) {
  long long r = 1;
  while (p) {
    if (p & 1) r = modMul(r, b);
    b = modMul(b, b);
    p >>= 1;
  }
  return r;
}
inline long long modInverse(long long a) { return modPow(a, 1000000007 - 2); }
inline long long modDiv(long long a, long long b) {
  return modMul(a, modInverse(b));
}
const long long N = 310, M = 50100;
long long vis[N], par[N], a[N], b[N], sum[N];
vector<long long> adjList[N];
vector<long long> path;
vector<pair<long long, long long> > store[N];
vector<pair<pair<long long, long long>, long long> > ans;
long long find_set(long long x) {
  if (x != par[x]) return par[x] = find_set(par[x]);
  return x;
}
void NO() {
  cout << "NO" << '\n';
  exit(0);
}
void mkpath(long long l, long long r) {
  path.clear();
  memset(vis, 0, sizeof(vis));
  queue<long long> bfs;
  bfs.push(l);
  memset(vis, 0, sizeof(vis));
  memset(par, -1, sizeof(par));
  vis[l] = true;
  while (!vis[r]) {
    long long u = bfs.front();
    bfs.pop();
    for (auto v : adjList[u]) {
      ;
      if (vis[v]) continue;
      vis[v] = true;
      bfs.push(v);
      par[v] = u;
    }
  };
  for (long long u = r; u != -1LL; u = par[u]) path.emplace_back(u);
  ;
}
void solve(long long idx, long long val) {
  if (idx == 0) return;
  ans.emplace_back(make_pair(make_pair(path[idx - 1], path[idx]),
                             min(a[path[idx - 1]], val)));
  solve(idx - 1, val);
  if (val > a[path[idx - 1]])
    ans.emplace_back(make_pair(make_pair(path[idx - 1], path[idx]),
                               max(0LL, val - a[path[idx - 1]])));
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long n, v, e;
  cin >> n >> v >> e;
  long long sum_a = 0, sum_b = 0;
  for (long long i = 0; i < n; ++i) cin >> a[i];
  for (long long i = 0; i < n; ++i) cin >> b[i];
  for (long long i = 0; i < n; ++i) par[i] = i;
  for (long long i = 0; i < e; ++i) {
    long long u, v;
    cin >> u >> v;
    --u;
    --v;
    adjList[u].emplace_back(v);
    adjList[v].emplace_back(u);
    long long u_p = find_set(u);
    long long v_p = find_set(v);
    par[u_p] = v_p;
  }
  for (long long i = 0; i < n; ++i) {
    store[find_set(i)].emplace_back(pair<long long, long long>(b[i] - a[i], i));
    sum[par[i]] += b[i] - a[i];
  }
  for (long long i = 0; i < n; ++i) {
    ;
    if (sum[i]) NO();
    sort(store[i].begin(), store[i].end(),
         greater<pair<long long, long long> >());
    ;
    long long l = 0, r = store[i].size() - 1LL;
    while (l < r) {
      long long val = min(abs(store[i][l].first), abs(store[i][r].first));
      mkpath(store[i][l].second, store[i][r].second);
      ;
      solve(path.size() - 1, val);
      a[store[i][l].second] += val;
      a[store[i][r].second] -= val;
      store[i][l].first -= val;
      store[i][r].first += val;
      if (!store[i][l].first) ++l;
      if (!store[i][r].first) --r;
    }
  }
  cout << ans.size() << '\n';
  for (auto it : ans)
    cout << it.first.first + 1 << " " << it.first.second + 1 << " " << it.second
         << '\n';
  return 0;
}