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>
#pragma GCC optimize(2)
using namespace std;
const int INF = 0x3f3f3f3f;
vector<pair<pair<int, int>, int> > tubes;
int vis[303];
vector<int> g[303];
int v;
int a[303], b[303];
long long A, B;
int n, e;
void dfs(int now) {
  vis[now] = 1;
  A += a[now];
  B += b[now];
  for (auto it : g[now]) {
    if (!vis[it]) dfs(it);
  }
}
int fa[303];
vector<int> order;
vector<int> tree_edges[303];
void build(int now, int pre = 0) {
  fa[now] = pre;
  vis[now] = 2;
  order.push_back(now);
  for (auto it : g[now]) {
    if (vis[it] != 2) {
      tree_edges[now].push_back(it);
      tree_edges[it].push_back(now);
      build(it, now);
    }
  }
}
bool updated[303];
void pull_up(int index) {
  for (auto it : tree_edges[index]) {
    if (it != fa[index]) {
      int can = min(v - a[index], a[it]);
      if (updated[it]) can = min(can, a[it] - b[it]);
      if (can) tubes.push_back(make_pair(make_pair(it, index), can));
      a[it] -= can;
      a[index] += can;
      pull_up(it);
    }
  }
}
void work(int root) {
  order.clear();
  build(root);
  for (auto it : order) {
    int to = fa[it];
    int from = it;
    while (to) {
      int can = v - a[to];
      if (min(a[from], can)) {
        tubes.push_back(make_pair(make_pair(from, to), min(a[from], can)));
        a[to] += min(a[from], can);
        a[from] -= min(a[from], can);
      }
      from = to;
      to = fa[to];
    }
  }
  for (auto it : order) assert(a[it] <= v);
  reverse(order.begin(), order.end());
  for (int i = 1; i <= n; ++i) {
    bool ok = 0;
    for (auto it : order) {
      if (updated[it]) continue;
      if (a[it] >= b[it])
        ;
      else {
        ok = 1;
        int needs = b[it] - a[it];
        vector<int> way;
        int to = fa[it];
        while (to) {
          way.push_back(to);
          if (a[to] >= needs) {
            break;
          }
          to = fa[to];
        }
        reverse(way.begin(), way.end());
        way.push_back(it);
        for (int i = 0; i < way.size() - 1; ++i) {
          int move = min(a[way[i]], v - a[way[i + 1]]);
          move = min(move, needs);
          a[way[i]] -= move;
          a[way[i + 1]] += move;
          tubes.push_back(make_pair(make_pair(way[i], way[i + 1]), move));
        }
        updated[it] = 1;
        pull_up(root);
        break;
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> v >> e;
  for (int i = 1; i <= n; ++i) cin >> a[i];
  for (int i = 1; i <= n; ++i) cin >> b[i];
  for (int i = 1; i <= e; ++i) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      A = B = 0;
      dfs(i);
      if (A != B) {
        cout << "NO\n";
        return 0;
      }
      work(i);
    }
  }
  cout << tubes.size() << endl;
  for (auto it : tubes) {
    cout << it.first.first << ' ' << it.first.second << ' ' << it.second
         << endl;
  }
  return 0;
}