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;
void dbg(const char* fmt, ...) {}
struct Move {
  int from, to, volume;
  Move(int _from, int _to, int _volume)
      : from(_from), to(_to), volume(_volume) {
    if (volume < 0) {
      swap(to, from);
      volume = -volume;
    }
  }
  void print() const { printf("%d %d %d\n", from + 1, to + 1, volume); }
};
void dfs(int s, vector<vector<int> >& ed, vector<bool>& used,
         vector<vector<int> >& tree) {
  used[s] = true;
  for (int i = 0; i < int(ed[s].size()); ++i) {
    int v = ed[s][i];
    if (used[v]) continue;
    tree[v].push_back(s);
    tree[s].push_back(v);
    dfs(v, ed, used, tree);
  }
}
void makeMove(int from, int to, int volume, vector<int>& a, vector<int>& b,
              vector<Move>& moves, int V) {
  if (volume == 0) return;
  a[from] -= volume;
  a[to] += volume;
  moves.push_back(Move(from, to, volume));
  if (a[from] < 0 || a[from] > V || a[to] < 0 || a[to] > V) throw 42;
}
int push(int v, int p, int delta, vector<int>& a, vector<int>& b,
         vector<vector<int> >& ed, vector<Move>& moves, int V) {
  dbg("push(%d %d %d)\n", v, p, delta);
  int total = 0;
  if (delta > 0) {
    int cur = min(delta, V - a[v]);
    makeMove(p, v, cur, a, b, moves, V);
    delta -= cur;
    total += cur;
  } else if (delta < 0) {
    int cur = max(delta, -a[v]);
    makeMove(p, v, cur, a, b, moves, V);
    delta -= cur;
    total += cur;
  }
  int total2 = 0;
  for (int i = 0; i < int(ed[v].size()); ++i) {
    int u = ed[v][i];
    if (u == p) continue;
    int cur = push(u, v, delta - total2, a, b, ed, moves, V);
    total2 += cur;
  }
  if (delta > 0) {
    int cur = min(delta, V - a[v]);
    makeMove(p, v, cur, a, b, moves, V);
    delta -= cur;
    total += cur;
  } else if (delta < 0) {
    int cur = max(delta, -a[v]);
    makeMove(p, v, cur, a, b, moves, V);
    delta -= cur;
    total += cur;
  }
  return total;
}
bool tryCutLeaf(int v, vector<int>& a, vector<int>& b, vector<vector<int> >& ed,
                vector<Move>& moves, int V) {
  if (ed[v].size() == 0) return a[v] == b[v];
  if (ed[v].size() != 1) throw 42;
  int u = ed[v][0];
  push(u, v, a[v] - b[v], a, b, ed, moves, V);
  ed[v].pop_back();
  int i = 0;
  while (ed[u][i] != v) ++i;
  ed[u].erase(ed[u].begin() + i);
  return a[v] == b[v];
}
int main() {
  int n, v, e;
  scanf("%d%d%d", &n, &v, &e);
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; ++i) scanf("%d", &a[i]);
  for (int j = 0; j < n; ++j) scanf("%d", &b[j]);
  vector<vector<int> > ed(n, vector<int>());
  for (int i = 0; i < e; ++i) {
    int u, v;
    scanf("%d%d", &u, &v);
    --u, --v;
    ed[u].push_back(v);
    ed[v].push_back(u);
  }
  vector<bool> used(n, false);
  vector<vector<int> > tree(n, vector<int>());
  for (int i = 0; i < n; ++i) {
    if (!used[i]) {
      dfs(i, ed, used, tree);
    }
  }
  for (int i = 0; i < n; ++i) {
    dbg("%d:", i);
    for (int j = 0; j < int(tree[i].size()); ++j) dbg(" %d", tree[i][j]);
    dbg("\n");
  }
  vector<Move> moves;
  vector<bool> cut(n, false);
  for (int i = 0; i < n; ++i) {
    int j = 0;
    while (j < n && (cut[j] || int(tree[j].size()) > 1)) ++j;
    cut[j] = true;
    if (!tryCutLeaf(j, a, b, tree, moves, v)) {
      printf("NO\n");
      return 0;
    }
  }
  printf("%d\n", (int)moves.size());
  for (int i = 0; i < int(moves.size()); ++i) moves[i].print();
  return 0;
}