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> g[333];
bool con[333][333];
int a[333];
int b[333];
int t[333];
long long d[333];
int n, m;
int up[333];
struct trans {
  int x, y, d;
  trans() {}
  trans(const int &_x, const int &_y, const int &_d) {
    x = _x;
    y = _y;
    d = _d;
  }
  void print(void) const { printf("%d %d %d\n", x, y, d); }
};
vector<trans> res;
int min(const int &x, const int &y) {
  if (x < y)
    return (x);
  else
    return (y);
}
int find(const int &x) {
  if (up[x] < 0) return (x);
  up[x] = find(up[x]);
  return (up[x]);
}
void join(const int &a, const int &b) {
  int x = find(a);
  int y = find(b);
  if (x == y) return;
  d[x] += d[y];
  up[y] = x;
}
void loadgraph(void) {
  scanf("%d", &n);
  scanf("%d", &m);
  scanf("%d", &m);
  int i, u, v;
  for (i = 1; i <= n; i = i + 1) scanf("%d", &a[i]);
  for (i = 1; i <= n; i = i + 1) scanf("%d", &b[i]);
  for (i = 1; i <= m; i = i + 1) {
    scanf("%d", &u);
    scanf("%d", &v);
    if (con[u][v]) continue;
    g[u].push_back(v);
    g[v].push_back(u);
    con[u][v] = true;
    con[v][u] = true;
  }
}
void addtrans(const int &x, const int &y, const int &d) {
  res.push_back(trans(x, y, d));
  a[x] -= d;
  a[y] += d;
  assert(res.size() <= 2 * n * n);
}
void checkans(void) {
  int i, j;
  for (i = 1; i <= n; i = i + 1) {
    up[i] = -1;
    d[i] = a[i] - b[i];
  }
  for (i = 1; i <= n; i = i + 1)
    for (j = i + 1; j <= n; j = j + 1)
      if (con[i][j]) join(i, j);
  for (i = 1; i <= n; i = i + 1)
    if (up[i] < 0 && d[i] != 0LL) {
      printf("NO");
      exit(0);
    }
}
void findway(const int &s, const int &f) {
  memset(t, 0, sizeof t);
  queue<int> q;
  while (!q.empty()) q.pop();
  q.push(s);
  t[s] = -1;
  int i, u, v;
  while (!q.empty()) {
    u = q.front();
    q.pop();
    if (u == f) return;
    for (i = 0; i < g[u].size(); i = i + 1) {
      v = g[u][i];
      if (t[v] == 0) {
        t[v] = u;
        q.push(v);
      }
    }
  }
  assert(false);
}
void transfer(const int &s, const int &f, const int &d) {
  if (s == f) return;
  int u = t[f];
  int del = min(a[u], d);
  int rem = d - del;
  addtrans(u, f, del);
  transfer(s, u, d);
  if (rem > 0) addtrans(u, f, rem);
}
bool fill(void) {
  int i, j;
  for (i = 1; i <= n; i = i + 1)
    if (a[i] > b[i]) break;
  if (i > n) return (false);
  for (j = 1; j <= n; j = j + 1)
    if (find(i) == find(j) && a[j] < b[j]) break;
  assert(j <= n);
  findway(i, j);
  int d = min(a[i] - b[i], b[j] - a[j]);
  transfer(i, j, d);
  return (true);
}
void process(void) {
  while (fill())
    ;
  printf("%d\n", res.size());
  int i;
  for (i = 0; i < res.size(); i = i + 1) res[i].print();
}
int main(void) {
  loadgraph();
  checkans();
  process();
  return 0;
}