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;
struct Move {
  int X, Y, W;
};
int Get() {
  char c;
  while (c = getchar(), (c < '0' || c > '9') && (c != '-'))
    ;
  bool Flag = (c == '-');
  if (Flag) c = getchar();
  int X = 0;
  while (c >= '0' && c <= '9') {
    X = X * 10 + c - 48;
    c = getchar();
  }
  return Flag ? -X : X;
}
void Output(int X) {
  if (X < 0) {
    putchar('-');
    X = -X;
  }
  int Len = 0, Data[10];
  while (X) {
    Data[Len++] = X % 10;
    X /= 10;
  }
  if (!Len) Data[Len++] = 0;
  while (Len--) putchar(Data[Len] + 48);
  putchar('\n');
}
int A[300], B[300];
vector<int> G[300];
int Len;
int Path[300];
bool Flag[300];
bool DFS(int X, int Depth) {
  if (Flag[X]) return false;
  Flag[X] = true;
  Path[Depth] = X;
  if (A[X] < B[X]) {
    Len = Depth + 1;
    return true;
  }
  for (int i = 0; i < G[X].size(); i++)
    if (DFS(G[X][i], Depth + 1)) return true;
  return false;
}
int main() {
  int N = Get(), MaxV = Get(), M = Get(), Sum = 0;
  for (int i = 0; i < N; i++) A[i] = Get();
  for (int i = 0; i < N; i++) B[i] = Get();
  for (int i = 0; i < M; i++) {
    int X = Get() - 1, Y = Get() - 1;
    G[X].push_back(Y);
    G[Y].push_back(X);
  }
  vector<Move> Ans;
  for (int i = 0; i < N; i++)
    while (A[i] > B[i]) {
      memset(Flag, 0, sizeof(Flag));
      if (!DFS(i, 0)) {
        cout << "NO" << endl;
        return 0;
      }
      int U = i, V = Path[Len - 1];
      int K = min(A[U] - B[U], B[V] - A[V]);
      static int Send[300];
      for (int j = 0; j < Len - 1; j++) {
        int P = Path[j], Q = Path[j + 1];
        int Real = min(K, min(A[P], MaxV - A[Q]));
        A[P] -= Real;
        A[Q] += Real;
        Send[j] = Real;
        if (Real) Ans.push_back((Move){P, Q, Real});
      }
      for (int j = Len - 1; j; j--) {
        int P = Path[j], Q = Path[j - 1];
        int Real = min(K - Send[j - 1], min(MaxV - A[P], A[Q]));
        A[P] += Real;
        A[Q] -= Real;
        if (Real) Ans.push_back((Move){Q, P, Real});
      }
    }
  for (int i = 0; i < N; i++)
    if (A[i] != B[i]) {
      cout << "NO" << endl;
      return 0;
    }
  cout << Ans.size() << endl;
  for (int i = 0; i < Ans.size(); i++)
    cout << Ans[i].X + 1 << ' ' << Ans[i].Y + 1 << ' ' << Ans[i].W << endl;
  return 0;
}