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>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse3,sse4,popcnt,avx,mmx,abm,tune=native")
using namespace std;
namespace output {
void __(short x) { cout << x; }
void __(unsigned x) { cout << x; }
void __(int x) { cout << x; }
void __(long long x) { cout << x; }
void __(unsigned long long x) { cout << x; }
void __(double x) { cout << x; }
void __(long double x) { cout << x; }
void __(char x) { cout << x; }
void __(const char* x) { cout << x; }
void __(const string& x) { cout << x; }
void __(bool x) { cout << (x ? "true" : "false"); }
template <class S, class T>
void __(const pair<S, T>& x) {
  __(1 ? "(" : ""), __(x.first), __(1 ? ", " : " "), __(x.second),
      __(1 ? ")" : "");
}
template <class T>
void __(const vector<T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
template <class T>
void __(const set<T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
template <class T>
void __(const multiset<T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
template <class S, class T>
void __(const map<S, T>& x) {
  __(1 ? "{" : "");
  bool _ = 0;
  for (const auto& v : x) __(_ ? 1 ? ", " : " " : ""), __(v), _ = 1;
  __(1 ? "}" : "");
}
void pr() { cout << "\n"; }
template <class S, class... T>
void pr(const S& a, const T&... b) {
  __(a);
  if (sizeof...(b)) __(' ');
  pr(b...);
}
}  // namespace output
using namespace output;
const int MN = 333, MM = 5e4 + 5;
int n, m, k, i, j, x, y, a[MN], r[MN], par[MN][MN], arr[MN];
long long sm;
vector<int> adj[MN];
queue<int> q;
struct sna {
  int x, y, w;
};
vector<sna> ans;
inline void process(int x, int y, int sh) {
  int cur = y, nxt = 0;
  while (cur != 0) {
    arr[++nxt] = cur;
    cur = par[x][cur];
  }
  vector<sna> edd;
  for (int i = 2, j; i <= nxt; i = j + 1) {
    for (j = i; j <= nxt && a[arr[j]] < sh; j++) {
    }
    vector<sna> tmp;
    for (int k = min(j, nxt); k >= i; k--) {
      assert(a[arr[k]] >= sh);
      if (a[arr[k - 1]] + sh > m) {
        int hm = max(0, sh - a[arr[k - 1]]);
        a[arr[k]] -= hm, a[arr[k - 1]] += hm;
        r[arr[k]] -= hm, r[arr[k - 1]] += hm;
        ans.push_back({arr[k], arr[k - 1], hm});
        tmp.push_back({arr[k], arr[k - 1], sh - hm});
      } else {
        ans.push_back({arr[k], arr[k - 1], sh});
        a[arr[k]] -= sh;
        a[arr[k - 1]] += sh;
        r[arr[k]] -= sh, r[arr[k - 1]] += sh;
      }
    }
    reverse(tmp.begin(), tmp.end());
    for (auto v : tmp) edd.push_back(v);
  }
  for (auto v : edd) {
    ans.push_back(v);
    a[v.x] -= v.w, a[v.y] += v.w;
    r[v.x] -= v.w, r[v.y] += v.w;
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (i = 1; i <= n; i++) {
    scanf("%d", &x);
    r[i] = a[i] - x;
    sm += r[i];
  }
  for (i = 1; i <= k; i++) {
    scanf("%d%d", &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  for (i = 1; i <= n; i++) {
    memset(par[i], -1, sizeof(par[i]));
    q.push(i);
    par[i][i] = 0;
    while (q.size()) {
      x = q.front();
      q.pop();
      for (auto v : adj[x]) {
        if (par[i][v] == -1) {
          par[i][v] = x;
          q.push(v);
        }
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (r[i] <= 0) continue;
    for (j = 1; j <= n; j++) {
      if (r[j] < 0 && r[i] > 0 && par[i][j] >= 0) {
        int sh = min(abs(r[j]), abs(r[i]));
        process(i, j, sh);
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (r[i] <= 0) continue;
    for (j = 1; j <= n; j++) {
      if (r[j] < 0 && r[i] > 0 && par[i][j] >= 0) {
        int sh = min(abs(r[j]), abs(r[i]));
        process(i, j, sh);
      }
    }
  }
  for (i = 1; i <= n; i++) {
    if (r[i]) sm = 1;
  }
  if (sm)
    printf("NO\n");
  else {
    printf("%d\n", ans.size());
    for (auto v : ans) printf("%d %d %d\n", v.x, v.y, v.w);
  }
  return 0;
}