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 MAX = 305;
int N, V, E;
int A[MAX], B[MAX];
set<int> adj[MAX];
int comp[MAX];
bool mark[MAX];
vector<int> path;
vector<int> X, Y, D;
void dfs(int v, long long &a, long long &b, int c) {
  comp[v] = c;
  a += A[v], b += B[v];
  for (set<int>::iterator it = adj[v].begin(); it != adj[v].end(); ++it) {
    int w = *it;
    if (comp[w]) continue;
    dfs(w, a, b, c);
  }
}
bool find_path(int v, int t) {
  mark[v] = true;
  path.push_back(v);
  if (v == t) return true;
  for (set<int>::iterator it = adj[v].begin(); it != adj[v].end(); ++it) {
    int w = *it;
    if (mark[w]) continue;
    if (find_path(w, t)) return true;
  }
  path.pop_back();
  return false;
}
void go(int i, int j, int d) {
  int v = path[i], w = path[j];
  if (i + 1 == j) {
    A[v] -= d;
    A[w] += d;
    X.push_back(v), Y.push_back(w), D.push_back(d);
    return;
  }
  int k = j - 1;
  int tt = min(A[path[k]], d);
  go(k, j, tt);
  go(i, k, d);
  go(k, j, d - tt);
}
int main() {
  ios::sync_with_stdio(false);
  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 v, w;
    cin >> v >> w;
    adj[v].insert(w);
    adj[w].insert(v);
  }
  for (int v = 1; v <= N; v++)
    if (!comp[v]) {
      long long a = 0, b = 0;
      dfs(v, a, b, v);
      if (a != b) {
        cout << "NO\n";
        return 0;
      }
    }
  for (int v = 1; v <= N; v++)
    while (A[v] > B[v]) {
      for (int w = 1; w <= N; w++)
        if (comp[w] == comp[v] && A[w] < B[w]) {
          int d = min(A[v] - B[v], B[w] - A[w]);
          path.clear();
          memset(mark, 0, sizeof(mark));
          find_path(v, w);
          go(0, (int)path.size() - 1, d);
          break;
        }
    }
  cout << X.size() << endl;
  for (int i = 0; i < (int)X.size(); i++)
    cout << X[i] << " " << Y[i] << " " << D[i] << endl;
  return 0;
}