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;
template <class T>
string ToString(T t) {
  stringstream s;
  s << t;
  return s.str();
}
template <class T>
void ToOther(T &t, string a) {
  stringstream s(a);
  s >> t;
}
int n, V, m;
int a[333];
int b[333];
bool g[333][333];
bool ck[333];
vector<int> t;
vector<int> v[555];
vector<int> r1, r2, r3;
vector<int> rr, rv;
void dfs(int x) {
  ck[x] = 1;
  t.push_back(x);
  for (int i = 0; i < n; i++)
    if (g[x][i] && !ck[i]) {
      v[x].push_back(i);
      v[i].push_back(x);
      dfs(i);
    }
}
bool flow(int p, int A, int &B, int &C) {
  if (A == B) {
    rr.push_back(B);
    rv.push_back(C);
    return 1;
  }
  for (int i = 0; i < v[A].size(); i++) {
    int k = v[A][i];
    if (p != k && flow(A, k, B, C)) {
      rr.push_back(A);
      rv.push_back(C);
      return 1;
    }
  }
  return 0;
}
bool make() {
  queue<int> A1, A2;
  queue<int> B1, B2;
  int tot = 0;
  for (int i = 0; i < t.size(); i++) {
    int &k = t[i];
    int dif = a[k] - b[k];
    tot += dif;
    if (dif > 0) A1.push(k), A2.push(dif);
    if (dif < 0) B1.push(k), B2.push(-dif);
  }
  if (tot != 0) return 0;
  while (A1.size()) {
    int &k = A1.front();
    int &S = A2.front();
    if (B1.size() == 0) break;
    while (S && B1.size()) {
      int &tar = B1.front();
      int &S2 = B2.front();
      int can = min(S, S2);
      rr.clear();
      rv.clear();
      flow(-1, k, tar, can);
      reverse((rr).begin(), (rr).end());
      int N = rr.size();
      while (1) {
        bool end = 1;
        for (int i = 0; i < N - 1; i++) {
          if (rv[i]) end = 0;
          int go = min(V - a[rr[i + 1]], min(a[rr[i]], rv[i]));
          if (go <= 0) continue;
          a[rr[i]] -= go;
          rv[i] -= go;
          a[rr[i + 1]] += go;
          r1.push_back(rr[i]);
          r2.push_back(rr[i + 1]);
          r3.push_back(go);
          if (r1.size() > n * n * 2)
            while (1)
              ;
        }
        if (end) break;
      }
      S -= can;
      S2 -= can;
      if (S2 == 0) B1.pop(), B2.pop();
    }
    if (S == 0) A1.pop(), A2.pop();
  }
}
int main() {
  cin >> n >> V >> m;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  while (m--) {
    int s, e;
    scanf("%d%d", &s, &e);
    s--;
    e--;
    g[s][e] = g[e][s] = 1;
  }
  for (int i = 0; i < n; i++)
    if (ck[i] == 0) {
      t.clear();
      dfs(i);
      if (!make()) {
        cout << "NO" << endl;
        return 0;
      }
    }
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) {
      cout << "NO" << endl;
      return 0;
    }
  cout << r1.size() << endl;
  for (int i = 0; i < r1.size(); i++)
    printf("%d %d %d\n", r1[i] + 1, r2[i] + 1, r3[i]);
}