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> node[301];
int b[301];
int c[301];
int parent[301];
bool visited[301];
stack<int> mo;
stack<int> le;
vector<pair<pair<int, int>, int>> ans;
bool find;
long long cpcum;
void checksum(int now) {
  visited[now] = 1;
  cpcum += (c[now] - b[now]);
  if (c[now] - b[now] > 0)
    mo.push(now);
  else if (c[now] - b[now] < 0)
    le.push(now);
  for (int i = 0; i < node[now].size(); i++) {
    int next = node[now][i];
    if (visited[next]) continue;
    checksum(next);
  }
}
bool dfs(int now, int s, int t) {
  for (int i = 0; i < node[now].size(); i++) {
    int next = node[now][i];
    if (parent[next] != -1) continue;
    parent[next] = now;
    if (next == t) {
      return true;
    }
    if (dfs(next, s, t)) return true;
  }
  return false;
}
void write(int s, int t, int d, int v) {
  if (parent[t] == s) {
    ans.push_back(make_pair(make_pair(s, t), d));
    c[s] -= d;
    c[t] += d;
    return;
  } else if (c[parent[t]] >= d) {
    c[t] += d;
    c[parent[t]] -= d;
    ans.push_back(make_pair(make_pair(parent[t], t), d));
    write(s, parent[t], d, v);
  } else {
    ans.push_back(make_pair(make_pair(parent[t], t), c[parent[t]]));
    int temp = c[parent[t]];
    c[parent[t]] = 0;
    write(s, parent[t], d, v);
    ans.push_back(make_pair(make_pair(parent[t], t), d - temp));
    c[t] += d;
    c[parent[t]] = temp;
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  int n, v, e;
  cin >> n >> v >> e;
  int sum = 0;
  for (int i = 1; i <= n; i++) {
    cin >> c[i];
    sum += c[i];
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    sum -= b[i];
  }
  if (sum != 0) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < e; i++) {
    int u, v;
    cin >> u >> v;
    node[u].push_back(v);
    node[v].push_back(u);
  }
  memset(visited, false, sizeof(visited));
  for (int i = 1; i <= n; i++) {
    if (visited[i] == false) {
      cpcum = 0;
      checksum(i);
      if (cpcum != 0) {
        cout << "NO" << endl;
        return 0;
      }
      while (mo.size() > 0) {
        int s = mo.top();
        int t = le.top();
        for (int i = 0; i <= n; i++) parent[i] = -1;
        parent[s] = 0;
        dfs(s, s, t);
        int d = min(c[s] - b[s], b[t] - c[t]);
        write(s, t, d, v);
        if (c[s] == b[s]) mo.pop();
        if (c[t] == b[t]) le.pop();
      }
    }
  }
  cout << ans.size() << endl;
  for (int i = 0; i < ans.size(); i++) {
    cout << ans[i].first.first << " " << ans[i].first.second << " "
         << ans[i].second << endl;
  }
  return 0;
}