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 int inf = 1000000007;
const long long linf = 1000000000000000000LL;
const double eps = 0.000001;
const double pi = 3.14159265358979323846;
template <class T>
T abs(T k) {
  return k >= 0 ? k : -k;
}
template <class T>
T sqr(T n) {
  return n * n;
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T mod(T a, T b) {
  return (a % b + b) % b;
}
template <class T>
T addmod(T a, T b, T c) {
  return (T)mod((long long)a + b, (long long)c);
}
template <class T>
T mulmod(T a, T b, T c) {
  return (T)mod((long long)a * b, (long long)c);
}
template <class T>
T powmod(T a, T b, T c) {
  return (T)(b ? mulmod(mod((T)sqr((long long)powmod(a, b >> 1, c)), c),
                        b & 1 ? a : 1, c)
               : 1);
}
template <class T>
void maxe(T &a, T b) {
  a = max(a, b);
}
template <class T>
void mine(T &a, T b) {
  a = min(a, b);
}
template <class T>
void mode(T &a, T b) {
  a = mod(a, b);
}
template <class T>
void addmode(T &a, T b, T c) {
  a = addmod(a, b, c);
}
template <class T>
void mulmode(T &a, T b, T c) {
  a = mulmod(a, b, c);
}
template <class T>
void powmode(T &a, T b, T c) {
  a = powmod(a, b, c);
}
void fileio_in_out() {
  freopen(".in", "r", stdin);
  freopen(".out", "w", stdout);
}
void fileio_txt() {
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
const int N = 333;
int test;
int n, m, k, ans;
int a[N], b[N];
pair<int, int> p[N];
int x, y;
vector<int> e[N];
int flag[N], ok[N];
pair<pair<int, int>, int> step[2 * N * N];
int check() {
  for (int i = 1; i <= n; i++)
    if (a[i] != b[i]) return 0;
  return 1;
}
void trans(int x, int y, int d) {
  step[ans++] = make_pair(make_pair(x, y), d);
  a[x] -= d;
  a[y] += d;
}
void dfs(int x, int w) {
  flag[x] = 1;
  w -= a[x];
  for (int i = 0; i < e[x].size(); i++) {
    int y = e[x][i];
    if (w > 0 && !flag[y]) {
      if (!ok[y]) {
        dfs(y, w);
        int d = min(w, a[y]);
        w -= d;
        trans(y, x, d);
      } else {
        trans(y, x, w);
        dfs(y, b[y]);
        w = 0;
        if (a[y] < b[y]) {
          w = b[y] - a[y];
          trans(x, y, w);
        }
      }
    }
  }
}
bool cmp(pair<int, int> a, pair<int, int> b) { return a > b; }
int main() {
  scanf("%d%d%d", &n, &k, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    p[i] = make_pair(b[i], i);
  }
  while (m--) {
    scanf("%d%d", &x, &y);
    e[x].push_back(y);
    e[y].push_back(x);
  }
  sort(p + 1, p + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    memset(flag, 0, sizeof(flag));
    dfs(p[i].second, p[i].first);
    ok[p[i].second] = 1;
  }
  if (check()) {
    printf("%d\n", ans);
    for (int i = 0; i < ans; i++)
      printf("%d %d %d\n", step[i].first.first, step[i].first.second,
             step[i].second);
  } else
    puts("NO");
  return 0;
}