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;
int N, V, E;
int mat[301][301];
int prevMat[301][301];
int A[301], B[301];
vector<pair<pair<int, int>, int> > R;
void flow2(vector<int>& P, int si, int ti, int d) {
  int i;
  if (si == ti) return;
  if (A[P[si + 1]] + d <= V) {
    A[P[si]] -= d;
    A[P[si + 1]] += d;
    R.push_back(make_pair(make_pair(P[si], P[si + 1]), d));
    flow2(P, si + 1, ti, d);
  } else {
    int d2 = V - A[P[si + 1]];
    A[P[si]] -= d2;
    A[P[si + 1]] += d2;
    if (d2 > 0) R.push_back(make_pair(make_pair(P[si], P[si + 1]), d2));
    flow2(P, si + 1, ti, d);
    A[P[si]] -= d - d2;
    A[P[si + 1]] += d - d2;
    R.push_back(make_pair(make_pair(P[si], P[si + 1]), d - d2));
  }
}
void flow(int s, int t, int d) {
  int i, j, y;
  vector<int> P;
  P.push_back(t);
  for (auto cur = t;;) {
    P.push_back(cur = prevMat[s][cur]);
    if (cur == s) {
      break;
    }
  }
  reverse(P.begin(), P.end());
  flow2(P, 0, P.size() - 1, d);
}
void solve() {
  int f, r, i, j, k, l, x, y;
  cin >> N >> V >> E;
  for (i = 0; i < N; ++i) cin >> A[i];
  for (i = 0; i < N; ++i) cin >> B[i];
  for (x = 0; x < N; ++x)
    for (y = 0; y < N; ++y) {
      mat[x][y] = 9999;
      prevMat[x][y] = x;
    }
  for (x = 0; x < N; ++x) mat[x][x] = 0;
  for (i = 0; i < E; ++i) {
    cin >> x >> y;
    mat[x - 1][y - 1] = mat[y - 1][x - 1] = 1;
    prevMat[x - 1][y - 1] = x - 1;
    prevMat[y - 1][x - 1] = y - 1;
  }
  for (i = 0; i < N; ++i)
    for (j = 0; j < N; ++j)
      for (k = 0; k < N; ++k) {
        if (mat[j][k] > mat[j][i] + mat[i][k]) {
          mat[j][k] = mat[j][i] + mat[i][k];
          prevMat[j][k] = prevMat[i][k];
        }
      }
  for (x = 0; x < N; ++x)
    for (y = 0; y < N; ++y) {
      if (mat[x][y] > N) continue;
      j = min(A[x] - B[x], B[y] - A[y]);
      if (j <= 0) continue;
      flow(x, y, j);
    }
  for (x = 0; x < N; ++x)
    if (A[x] != B[x]) return (void)printf("NO\n");
  printf("%d\n", R.size());
  for (i = 0; i < R.size(); ++i)
    printf("%d %d %d\n", R[i].first.first + 1, R[i].first.second + 1,
           R[i].second);
}
int main() {
  solve();
  return 0;
}