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;
inline int Get_Int() {
  int Num = 0, Flag = 1;
  char ch;
  do {
    ch = getchar();
    if (ch == '-') Flag = -Flag;
  } while (ch < '0' || ch > '9');
  do {
    Num = Num * 10 + ch - '0';
    ch = getchar();
  } while (ch >= '0' && ch <= '9');
  return Num * Flag;
}
int N, M, Limit, Total, K;
int Now[305], End[305], Ans[305 * 305 * 2][3];
bool Visited[305], Deleted[305];
vector<int> To[305];
int BFS(int S) {
  int Now;
  memset(Visited, false, sizeof(Visited));
  Visited[S] = true;
  queue<int> Queue;
  Queue.push(S);
  while (!Queue.empty()) {
    Now = Queue.front();
    Queue.pop();
    for (typeof(To[Now].begin()) it = To[Now].begin(); it != To[Now].end();
         ++it)
      if (!Visited[*it] && !Deleted[*it]) {
        Visited[*it] = true;
        Queue.push(*it);
      }
  }
  return Now;
}
int DFS(int x, int Need) {
  int Rest = Need;
  if (!Need) return 0;
  Visited[x] = true;
  for (typeof(To[x].begin()) it = To[x].begin(); it != To[x].end(); ++it)
    if (!Visited[*it] && !Deleted[*it]) {
      int Increment;
      if (Need > 0)
        Increment = min(Rest, Now[*it]);
      else
        Increment = max(Rest, Now[*it] - Limit);
      Increment += DFS(*it, Rest - Increment);
      Rest -= Increment;
      ++K;
      Ans[K][0] = *it;
      Ans[K][1] = x;
      Ans[K][2] = Increment;
      Now[*it] -= Increment;
      Now[x] += Increment;
      if (!Rest) return Need;
    }
  return Need - Rest;
}
int main() {
  cin >> N >> Limit >> M;
  for (int i = 1; i <= N; ++i) Now[i] = Get_Int();
  for (int i = 1; i <= N; ++i) End[i] = Get_Int();
  for (int i = 1; i <= M; ++i) {
    int x = Get_Int(), y = Get_Int();
    To[x].push_back(y);
    To[y].push_back(x);
  }
  for (int i = 1; i <= N; ++i)
    while (!Deleted[i]) {
      int S = BFS(i);
      Total = 0;
      memset(Visited, false, sizeof(Visited));
      int Flow = End[S] - Now[S];
      if (Flow != DFS(S, End[S] - Now[S])) {
        printf("NO\n");
        return 0;
      }
      Deleted[S] = true;
    }
  cout << K << endl;
  for (int i = 1; i <= K; ++i)
    if (Ans[i][2] > 0)
      printf("%d %d %d\n", Ans[i][0], Ans[i][1], Ans[i][2]);
    else
      printf("%d %d %d\n", Ans[i][1], Ans[i][0], -Ans[i][2]);
  return 0;
}