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 long N = 300 + 7;
long long n;
long long m;
long long lim;
long long a[N];
long long b[N];
bool vis[N];
bool vis2[N];
vector<long long> nodes;
vector<long long> g[N];
void dfs(long long a) {
  vis[a] = 1;
  for (auto &b : g[a])
    if (vis[b] == 0) {
      dfs(b);
    }
  nodes.push_back(a);
}
struct T {
  long long x;
  long long y;
  long long w;
};
vector<T> sol;
void add(long long x, long long y, long long w) {
  if (w == 0) return;
  a[x] -= w;
  a[y] += w;
  sol.push_back({x, y, w});
  assert(0 <= a[x] && a[x] <= lim);
  assert(0 <= a[y] && a[y] <= lim);
}
void print() {
  cout << (long long)sol.size() << "\n";
  for (auto &it : sol) {
    cout << it.x << " " << it.y << " " << it.w << "\n";
  }
}
bool found;
vector<long long> path;
vector<long long> cur;
void fpath(long long x, long long y) {
  if (found) return;
  cur.push_back(x);
  if (x == y) {
    found = 1;
    path = cur;
    cur.pop_back();
    return;
  }
  vis2[x] = 1;
  for (auto &k : g[x]) {
    if (vis2[k] == 0) {
      fpath(k, y);
    }
  }
  cur.pop_back();
}
void send(long long pos, long long d) {
  if (pos == 0) return;
  long long x = path[pos];
  long long x2 = path[pos - 1];
  long long t = min(d, a[x2]);
  add(x2, x, t);
  send(pos - 1, d);
  add(x2, x, d - t);
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> lim >> m;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  for (long long i = 1; i <= n; i++) cin >> b[i];
  for (long long i = 1; i <= m; i++) {
    long long x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  for (long long xn = 1; xn <= n; xn++) {
    if (vis[xn] == 0) {
      nodes.clear();
      dfs(xn);
      long long dif = 0;
      for (auto &x : nodes) dif += a[x] - b[x];
      if (dif != 0) {
        cout << "NO\n";
        return 0;
      }
      while (1) {
        long long s = -1, t = -1;
        for (auto &x : nodes) {
          if (a[x] > b[x]) {
            s = x;
          }
          if (a[x] < b[x]) {
            t = x;
          }
        }
        if (s == -1) {
          break;
        }
        assert(t != -1);
        for (auto &x : nodes) vis2[x] = 0;
        found = 0;
        cur.clear();
        path.clear();
        fpath(s, t);
        assert(found);
        send((long long)path.size() - 1, min(a[s] - b[s], b[t] - a[t]));
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    assert(a[i] == b[i]);
  }
  print();
}