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>
char ch;
inline void read(int &x) {
  x = 0;
  ch = getchar();
  while (ch <= 32) ch = getchar();
  while (ch > 32) {
    x = x * 10 + ch - 48;
    ch = getchar();
  };
};
inline void die() {
  puts("NO");
  exit(0);
};
int n, V, m;
int a[305], b[305];
struct edge {
  edge *next;
  int y;
};
edge *se[305], e[305 * 2], *etot = e;
inline void addedge(int x, int y) {
  *++etot = (edge){se[x], y};
  se[x] = etot;
};
int fa[305];
inline int getfa(int x) { return fa[x] ? fa[x] = getfa(fa[x]) : x; };
bool visit[305];
long long _sum = 0;
inline void dfs(int x) {
  visit[x] = true;
  _sum += a[x] - b[x];
  edge *te = se[x];
  while (te) {
    int ty = te->y;
    if (!visit[ty]) {
      dfs(ty);
    };
    te = te->next;
  };
};
int _x[305 * 305], _y[305 * 305], _d[305 * 305];
int _tot;
inline void addop(int x, int y, int d) {
  _x[++_tot] = x;
  _y[_tot] = y;
  _d[_tot] = d;
};
bool ok[305];
inline int push(int x, int last, int d) {
  if (V - a[x] >= d) {
    addop(last, x, d);
    a[x] += d;
    return d;
  };
  int ret = V - a[x];
  edge *te = se[x];
  while (te) {
    int ty = te->y;
    if (ty ^ last && !ok[ty]) {
      int tmp = push(ty, x, d - ret);
      ret += tmp;
      if (ret == d) break;
    };
    te = te->next;
  };
  addop(last, x, ret);
  a[x] = V;
  return ret;
};
inline void push(int x, int d) {
  edge *te = se[x];
  while (te) {
    int ty = te->y;
    if (!ok[ty]) {
      int tmp = push(ty, x, d);
      d -= tmp;
      if (!d) break;
    };
    te = te->next;
  };
};
inline int pull(int x, int last, int d) {
  if (a[x] >= d) {
    addop(x, last, d);
    a[x] -= d;
    return d;
  };
  int ret = a[x];
  edge *te = se[x];
  while (te) {
    int ty = te->y;
    if (ty ^ last && !ok[ty]) {
      int tmp = pull(ty, x, d - ret);
      ret += tmp;
      if (ret == d) break;
    };
    te = te->next;
  };
  addop(x, last, ret);
  a[x] = 0;
  return ret;
};
inline void pull(int x, int d) {
  edge *te = se[x];
  while (te) {
    int ty = te->y;
    if (!ok[ty]) {
      int tmp = pull(ty, x, d);
      d -= tmp;
      if (!d) break;
    };
    te = te->next;
  };
};
inline void balance(int x) {
  ok[x] = true;
  if (a[x] == b[x]) return;
  if (a[x] > b[x]) {
    push(x, a[x] - b[x]);
  } else {
    pull(x, b[x] - a[x]);
  };
  a[x] = b[x];
};
inline void dfs2(int x, int last) {
  edge *te = se[x];
  while (te) {
    int ty = te->y;
    if (ty ^ last) {
      dfs2(ty, x);
    };
    te = te->next;
  };
  balance(x);
};
inline void solve(int x) {
  _sum = 0;
  dfs(x);
  if (_sum != 0) die();
  dfs2(x, 0);
};
int aa[305];
int main() {
  read(n);
  read(V);
  read(m);
  int i;
  for (i = 1; i <= n; i++) {
    read(a[i]);
    aa[i] = a[i];
  };
  for (i = 1; i <= n; i++) {
    read(b[i]);
  };
  for (i = 1; i <= m; i++) {
    int x, y, X, Y;
    read(x);
    read(y);
    X = getfa(x);
    Y = getfa(y);
    if (X != Y) {
      addedge(x, y);
      addedge(y, x);
      fa[X] = Y;
    };
  };
  for (i = 1; i <= n; i++) {
    if (visit[i]) continue;
    solve(i);
  };
  printf("%d\n", _tot);
  for (i = 1; i <= _tot; i++) {
    printf("%d %d %d\n", _x[i], _y[i], _d[i]);
    aa[_x[i]] -= _d[i];
    aa[_y[i]] += _d[i];
  };
}