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;
vector<int> link[333];
int n, v, e;
int ai[333], bi[333];
struct toj {
  int ind, dat;
};
toj ts[333];
int minv(int i1, int i2) { return i1 < i2 ? i1 : i2; }
bool cmp(toj t1, toj t2) { return t1.dat > t2.dat; }
bool exist() {
  for (int i = 0; i != n; i++)
    if (ai[i] != bi[i]) return false;
  return true;
}
int ansx[333 * 333 * 2 + 9], ansy[333 * 333 * 2 + 9], ansd[333 * 333 * 2 + 9],
    ansp;
void addans(int x, int y, int d) {
  ansx[ansp] = x;
  ansy[ansp] = y;
  ansd[ansp] = d;
  ansp++;
  ai[x] -= d;
  ai[y] += d;
}
int vis[333], fin[333];
void dfs(int s, int des) {
  vis[s] = true;
  des -= ai[s];
  for (int i = 0; i != link[s].size(); i++) {
    int t = link[s][i];
    if (des <= 0 || vis[t]) continue;
    if (fin[t] && ai[t] >= des) {
      addans(t, s, des);
      dfs(t, bi[t]);
      if (ai[t] < bi[t]) {
        des = bi[t] - ai[t];
        addans(s, t, des);
      } else
        des = 0;
    } else {
      dfs(t, des);
      int d = minv(des, ai[t]);
      des -= d;
      addans(t, s, d);
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &v, &e);
  for (int i = 0; i != n; i++) scanf("%d", ai + i);
  for (int i = 0; i != n; i++) {
    scanf("%d", bi + i);
    ts[i].ind = i;
    ts[i].dat = bi[i];
  }
  for (int i = 0; i != e; i++) {
    int u, v;
    scanf("%d%d", &u, &v);
    u--;
    v--;
    link[u].push_back(v);
    link[v].push_back(u);
  }
  sort(ts, ts + n, cmp);
  memset(fin, 0, sizeof(fin));
  for (int i = 0; i != n; i++) {
    memset(vis, 0, sizeof(vis));
    dfs(ts[i].ind, ts[i].dat);
    fin[ts[i].ind] = true;
  }
  if (exist()) {
    printf("%d\n", ansp);
    for (int i = 0; i != ansp; i++)
      printf("%d %d %d\n", ansx[i] + 1, ansy[i] + 1, ansd[i]);
  } else
    puts("NO");
  return 0;
}