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;
const int INF = 1E9 + 7;
template <class C>
void mini(C& a4, C b4) {
  a4 = min(a4, b4);
}
template <class C>
void maxi(C& a4, C b4) {
  a4 = max(a4, b4);
}
int n, v, e;
int a[307], b[307];
vector<int> GG[307], G[307];
bool del[307], vis[307];
int xx[1000007], yy[1000007], dd[1000007], moves;
long long go(int x) {
  long long res = a[x] - b[x];
  vis[x] = true;
  for (__typeof((GG[x]).begin()) i = ((GG[x]).begin()); i != (GG[x]).end(); ++i)
    if (!vis[*i]) {
      G[x].push_back(*i);
      G[*i].push_back(x);
      res += go(*i);
    }
  return res;
}
void push(int x, int o, int lim, bool down) {
  for (__typeof((G[x]).begin()) i = ((G[x]).begin()); i != (G[x]).end(); ++i)
    if (*i != o && !del[*i]) {
      push(*i, x, INF, down);
      int can = lim;
      int l = x, r = *i;
      if (!down) swap(l, r);
      mini(can, a[l]);
      mini(can, v - a[r]);
      lim -= can;
      if (can > 0) {
        a[l] -= can;
        a[r] += can;
        xx[moves] = l;
        yy[moves] = r;
        dd[moves] = can;
        moves++;
      }
    }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  cin >> n >> v >> e;
  for (int i = (1); i <= (n); ++i) cin >> a[i];
  for (int i = (1); i <= (n); ++i) cin >> b[i];
  while (e--) {
    int x, y;
    cin >> x >> y;
    GG[x].push_back(y);
    GG[y].push_back(x);
  }
  for (int i = (1); i <= (n); ++i)
    if (!vis[i])
      if (go(i) != 0) {
        cout << "NO" << endl;
        return 0;
      }
  bool ok;
  do {
    ok = false;
    for (int i = (1); i <= (n); ++i)
      if (!del[i]) {
        int deg = 0;
        for (__typeof((G[i]).begin()) j = ((G[i]).begin()); j != (G[i]).end();
             ++j)
          deg += !del[*j];
        if (deg != 1) continue;
        if (a[i] != b[i]) push(i, i, abs(a[i] - b[i]), a[i] > b[i]);
        assert(a[i] == b[i]);
        del[i] = true;
        ok = true;
        break;
      }
  } while (ok);
  for (int i = (1); i <= (n); ++i) assert(a[i] == b[i]);
  cout << moves << endl;
  for (int i = 0; i < (moves); ++i)
    cout << xx[i] << " " << yy[i] << " " << dd[i] << endl;
  return 0;
}