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;
char buf[1 << 21], *p1 = buf, *p2 = buf;
template <class T>
void read(T &x) {
  x = 0;
  int c = getchar();
  int flag = 0;
  while (c < '0' || c > '9') flag |= (c == '-'), c = getchar();
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  if (flag) x = -x;
}
template <class T>
T _max(T a, T b) {
  return b < a ? a : b;
}
template <class T>
T _min(T a, T b) {
  return a < b ? a : b;
}
template <class T>
bool checkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
}
template <class T>
bool checkmin(T &a, T b) {
  return b < a ? a = b, 1 : 0;
}
const int M = 50005, N = 305;
int n, v, m;
int e = 0, first[N], nxt[M << 1], point[M << 1], deg[N];
long long a[N], b[N];
vector<int> G[N];
int q[N];
int son[N], vis[N], mark[N];
int w[N], top = 0;
struct node {
  int u, v, w;
  node(int u = 0, int v = 0, int w = 0) : u(u), v(v), w(w) {}
};
vector<node> ans;
void add_edge(int x, int y) {
  nxt[++e] = first[x];
  first[x] = e;
  point[e] = y;
}
int bfs(int s) {
  int head = 1, tail = 0;
  long long pa = 0, pb = 0;
  q[++tail] = s;
  vis[s] = 1;
  top = 0;
  while (head <= tail) {
    int x = q[head++];
    w[++top] = x;
    pa += a[x];
    pb += b[x];
    for (int i = first[x]; ~i; i = nxt[i]) {
      int to = point[i];
      if (vis[to]) continue;
      vis[to] = 1;
      G[x].push_back(to);
      G[to].push_back(x);
      ++deg[to];
      ++deg[x];
      q[++tail] = to;
    }
  }
  if (pa ^ pb)
    return 0;
  else
    return 1;
}
void In(int x, int f) {
  son[f] = x;
  for (int i = 0; i < (int)G[x].size(); ++i) {
    int to = G[x][i];
    if (to == f || mark[to]) continue;
    In(to, x);
    long long o = _min(v - a[x], a[to]);
    a[x] += o;
    a[to] -= o;
    if (o) ans.push_back(node(to, x, o));
  }
}
void Out(int x, int f) {
  son[f] = x;
  for (int i = 0; i < (int)G[x].size(); ++i) {
    int to = G[x][i];
    if (to == f || mark[to]) continue;
    Out(to, x);
    long long o = _min(v - a[to], a[x]);
    a[x] -= o;
    a[to] += o;
    if (o) ans.push_back(node(x, to, o));
  }
}
void adjust(int x) {
  mark[x] = 1;
  if (a[x] == b[x]) return;
  if (a[x] < b[x])
    In(x, 0);
  else
    Out(x, 0);
  if (a[x] > b[x]) {
    long long t = a[x] - b[x];
    ans.push_back(node(x, son[x], t));
    a[son[x]] += t;
    a[x] -= t;
  } else if (a[x] < b[x]) {
    long long t = b[x] - a[x];
    ans.push_back(node(son[x], x, t));
    a[son[x]] -= t;
    a[x] += t;
  }
}
void doit() {
  int head = 1, tail = 0;
  for (int i = 1; i <= top; ++i)
    if (deg[w[i]] == 1) q[++tail] = w[i];
  while (head <= tail) {
    int x = q[head++];
    adjust(x);
    for (int i = first[x]; ~i; i = nxt[i]) {
      int to = point[i];
      if ((--deg[to]) == 1) {
        q[++tail] = to;
      }
    }
  }
}
void init() {
  read(n);
  read(v);
  read(m);
  memset(first, -1, sizeof first);
  for (int i = 1; i <= n; ++i) read(a[i]);
  for (int i = 1; i <= n; ++i) read(b[i]);
  for (int i = 0, u, v; i < m; ++i) {
    read(u);
    read(v);
    add_edge(u, v);
    add_edge(v, u);
  }
}
void solve() {
  for (int i = 1; i <= n; ++i) {
    if (vis[i]) continue;
    if (!bfs(i)) {
      printf("NO\n");
      return;
    }
    doit();
  }
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < (int)ans.size(); ++i) {
    printf("%d %d %d\n", ans[i].u, ans[i].v, ans[i].w);
  }
}
int main() {
  init();
  solve();
  return 0;
}