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;
long long int aa[601];
long long int b[600];
long long int n, v, e;
vector<int> adjlist[301];
bool unfinished[301];
int parent[301];
stringstream ostrs;
int olen;
void _transfuse(int from, int to, long long int amount) {
  if (parent[from] == 0) return;
  if (amount + b[parent[from]] <= v) {
    b[parent[from]] += amount;
    b[from] -= amount;
    ostrs << from << " " << parent[from] << " " << amount << endl;
    olen++;
    _transfuse(parent[from], to, amount);
  } else if (b[parent[from]] >= amount) {
    olen++;
    _transfuse(parent[from], to, amount);
    b[parent[from]] += amount;
    b[from] -= amount;
    ostrs << from << " " << parent[from] << " " << amount << endl;
  } else {
    olen += 2;
    ostrs << from << " " << parent[from] << " " << v - b[parent[from]] << endl;
    long long int temp = amount - (v - b[parent[from]]);
    b[from] -= v - b[parent[from]];
    b[parent[from]] = v;
    _transfuse(parent[from], to, amount);
    b[from] -= temp;
    b[parent[from]] += temp;
    ostrs << from << " " << parent[from] << " " << temp << endl;
  }
}
void transfuse(int v1, int v2) {
  long long int of = b[v1] - aa[v1];
  long long int uf = aa[v2] - b[v2];
  if (of >= uf) {
    _transfuse(v1, v2, uf);
  } else {
    _transfuse(v1, v2, of);
  }
}
int main() {
  long long int cs = 0;
  cin >> n >> v >> e;
  bool pos = true;
  deque<int> todo;
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    if (aa[i] > v) pos = false;
    cs -= b[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> aa[i];
    if (aa[i] > v) pos = false;
    if (b[i] < aa[i]) {
      todo.push_back(i);
    }
    cs += aa[i];
  }
  if (cs != 0) pos = false;
  if (!pos) {
    cout << "NO";
    return 0;
  }
  int v1, v2;
  for (int i = 0; i < e; i++) {
    cin >> v1 >> v2;
    adjlist[v1].push_back(v2);
    adjlist[v2].push_back(v1);
  }
  bool done = false;
  while (!todo.empty()) {
    int e = todo.front();
    todo.pop_front();
    fill(parent, parent + n + 1, -1);
    deque<int> q;
    q.push_back(e);
    parent[e] = 0;
    bool fail = true;
    while (!q.empty()) {
      int nod = q.front();
      q.pop_front();
      if (b[nod] > aa[nod]) {
        transfuse(nod, e);
        if (b[nod] < aa[nod]) {
          todo.push_back(nod);
        } else if (b[e] < aa[e]) {
          todo.push_back(e);
        }
        fail = false;
        break;
      }
      for (vector<int>::iterator j = adjlist[nod].begin();
           j != adjlist[nod].end(); j++) {
        if (parent[*j] == -1) {
          q.push_back(*j);
          parent[*j] = nod;
        }
      }
    }
    if (fail) {
      cout << "NO";
      return 0;
    }
  }
  cout << olen << endl;
  cout << ostrs.str();
  return 0;
}