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;
int n, m;
int maxvol;
int d[300][300];
int nxt[300][300];
int have[300], want[300];
int nans;
int ans[180000][3];
int ndelay;
int delay[300][3];
void input() {
  scanf("%d%d%d", &n, &maxvol, &m);
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (n); ++j) {
      d[i][j] = i == j ? 0 : INT_MAX;
      nxt[i][j] = -1;
    }
  for (int i = (0); i < (n); ++i) scanf("%d", &have[i]);
  for (int i = (0); i < (n); ++i) scanf("%d", &want[i]);
  for (int i = (0); i < (m); ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a, --b;
    d[a][b] = d[b][a] = 1;
    nxt[a][b] = b;
    nxt[b][a] = a;
  }
}
bool solve() {
  for (int k = (0); k < (n); ++k)
    for (int i = (0); i < (n); ++i)
      for (int j = (0); j < (n); ++j)
        if (d[i][k] != INT_MAX && d[k][j] != INT_MAX &&
            d[i][k] + d[k][j] < d[i][j]) {
          d[i][j] = d[i][k] + d[k][j];
          nxt[i][j] = nxt[i][k];
        }
  nans = 0;
  while (true) {
    int from = -1;
    for (int i = (0); i < (n); ++i)
      if (have[i] > want[i]) {
        from = i;
        break;
      }
    if (from == -1) break;
    int to = -1;
    for (int i = (0); i < (n); ++i)
      if (have[i] < want[i] && d[from][i] != INT_MAX &&
          (to == -1 || d[from][i] < d[from][to]))
        to = i;
    if (to == -1) break;
    int amount = min(have[from] - want[from], want[to] - have[to]);
    ndelay = 0;
    for (int prev = from, at = nxt[from][to]; at != -1;
         prev = at, at = nxt[at][to]) {
      int now = min(amount, maxvol - have[at]);
      if (now > 0) {
        have[prev] -= now;
        have[at] += now;
        assert(nans < 180000);
        ans[nans][0] = prev;
        ans[nans][1] = at;
        ans[nans][2] = now;
        ++nans;
      }
      if (amount > now) {
        have[prev] -= (amount - now);
        have[at] += (amount - now);
        assert(ndelay < 300);
        delay[ndelay][0] = prev;
        delay[ndelay][1] = at;
        delay[ndelay][2] = amount - now;
        ++ndelay;
      }
    }
    for (int i = ndelay - 1; i >= 0; --i) {
      assert(nans < 180000);
      ans[nans][0] = delay[i][0];
      ans[nans][1] = delay[i][1];
      ans[nans][2] = delay[i][2];
      ++nans;
    }
  }
  for (int i = (0); i < (n); ++i)
    if (have[i] != want[i]) return false;
  return true;
}
void output(bool solved) {
  if (!solved) {
    printf("NO\n");
    return;
  }
  printf("%d\n", nans);
  for (int i = (0); i < (nans); ++i)
    printf("%d %d %d\n", ans[i][0] + 1, ans[i][1] + 1, ans[i][2]);
}
void run(int casenr) {
  input();
  bool ret = solve();
  output(ret);
}
int oldhave[300];
void test() {
  int seed = 1371310971;
  srand(seed);
  n = 100;
  m = 1000;
  maxvol = 1000;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (n); ++j) {
      d[i][j] = i == j ? 0 : INT_MAX;
      nxt[i][j] = -1;
    }
  for (int i = (0); i < (m); ++i) {
    int a = rand() % n, b = rand() % n;
    if (a == b) continue;
    d[a][b] = d[b][a] = 1;
    nxt[a][b] = b;
    nxt[b][a] = a;
  }
  int sum = maxvol * n * 9 / 10;
  {
    int left = sum;
    for (int i = (0); i < (n); ++i) {
      int maxrem = (n - i - 1) * maxvol;
      int minnow = left > maxrem ? left - maxrem : 0;
      int x = min(maxvol - minnow - 50, left);
      have[i] = x <= 0 ? minnow : minnow + rand() % x;
      left -= have[i];
    }
  }
  {
    int left = sum;
    for (int i = (0); i < (n); ++i) {
      int maxrem = (n - i - 1) * maxvol;
      int minnow = left > maxrem ? left - maxrem : 0;
      int x = min(maxvol - minnow - 50, left);
      want[i] = x <= 0 ? minnow : minnow + rand() % x;
      left -= want[i];
    }
  }
  for (int i = (0); i < (n); ++i) oldhave[i] = have[i];
  if (!solve()) {
    printf("not solved\n");
    return;
  }
  for (int i = (0); i < (n); ++i) have[i] = oldhave[i];
  for (int i = (0); i < (nans); ++i) {
    int a = ans[i][0], b = ans[i][1], c = ans[i][2];
    assert(d[a][b] == 1);
    assert(have[a] >= c);
    have[a] -= c;
    have[b] += c;
    assert(have[b] <= maxvol);
  }
  for (int i = (0); i < (n); ++i) assert(have[i] == want[i]);
}
int main() {
  run(1);
  return 0;
}