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 nn = 600;
int f[nn], a[nn], b[nn], v[nn], sum[nn], d[nn];
long long sa[nn], sb[nn];
int N, V, _E, opts, delta;
vector<int> E[nn], e[nn];
struct pp {
  int x, y, z;
} opt[nn * nn * 2];
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
void dfs(int x) {
  v[x] = 1;
  for (int i = 0; i < E[x].size(); ++i) {
    int j = E[x][i];
    if (v[j]) continue;
    if (delta <= 0) return;
    e[x].push_back(j);
    if (a[j] < b[j]) {
      sum[j] = b[j] - a[j];
      if (sum[j] > delta) sum[j] = delta;
      d[j] = sum[j];
      delta -= sum[j];
    }
    dfs(j);
    sum[x] += sum[j];
  }
}
void add(int x, int y, int z) {
  if (!z) return;
  opts++;
  opt[opts].x = x;
  opt[opts].y = y;
  opt[opts].z = z;
  a[x] -= z;
  a[y] += z;
}
int trans(int x, int y) {
  if (d[x] > 0) y -= d[x];
  for (int i = 0; i < e[x].size(); ++i) {
    int j = e[x][i];
    if (sum[j] > 0) {
      if (a[j] >= sum[j]) {
        trans(j, sum[j]);
        add(x, j, sum[j]);
      } else {
        int res = a[j];
        add(x, j, sum[j] - a[j]);
        trans(j, sum[j]);
        add(x, j, res);
      }
    }
  }
}
int main() {
  scanf("%d%d%d", &N, &V, &_E);
  for (int i = 1; i <= N; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= N; ++i) scanf("%d", &b[i]);
  for (int i = 1; i <= N; ++i) f[i] = i;
  for (int _ = 1; _ <= _E; ++_) {
    int x, y;
    scanf("%d%d", &x, &y);
    E[x].push_back(y);
    E[y].push_back(x);
    f[find(x)] = find(y);
  }
  for (int i = 1; i <= N; ++i)
    f[i] = find(f[i]), sa[f[i]] += a[i], sb[f[i]] += b[i];
  for (int i = 1; i <= N; ++i) {
    if (sa[i] != sb[i]) {
      puts("NO");
      return 0;
    }
  }
  for (int i = 1; i <= N; ++i) {
    if (a[i] <= b[i]) continue;
    for (int j = 1; j <= N; ++j) v[j] = 0, sum[j] = 0, d[j] = 0, e[j].clear();
    delta = a[i] - b[i];
    dfs(i);
    trans(i, a[i] - b[i]);
  }
  cout << opts << endl;
  for (int i = 1; i <= opts; ++i)
    cout << opt[i].x << ' ' << opt[i].y << ' ' << opt[i].z << endl;
  return 0;
}