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>
inline int size(const T& c) {
  return c.size();
}
using namespace std;
const int maxn = 300 + 10;
const int oo = 1000000000;
int a[maxn], b[maxn];
int d[maxn][maxn], u, v, top, n, e;
struct ketqua {
  int i;
  int j;
  int d;
} res[maxn * maxn * 3];
void add(int i, int j, int d) {
  a[i] -= d;
  a[j] += d;
  res[++top].i = i;
  res[top].j = j;
  res[top].d = d;
}
void go(int s, int e, int c) {
  if (d[s][e] == 1) {
    add(s, e, c);
    return;
  }
  for (int i = (1), _b = (n); i <= _b; i++) {
    if (i != s && i != e && d[i][e] == 1 && d[s][e] == d[s][i] + d[i][e]) {
      if (a[i] >= c) {
        add(i, e, c);
        go(s, i, c);
        return;
      } else {
        int rem = c - a[i];
        add(i, e, a[i]);
        go(s, i, c);
        add(i, e, rem);
        return;
      }
    }
  }
}
int main() {
  cin >> n >> v >> e;
  for (int i = (1), _b = (n); i <= _b; i++) cin >> a[i];
  for (int i = (1), _b = (n); i <= _b; i++) cin >> b[i];
  for (int i = (1), _b = (n); i <= _b; i++) {
    for (int j = (1), _b = (n); j <= _b; j++) d[i][j] = oo;
    d[i][i] = 0;
  }
  for (int i = (1), _b = (e); i <= _b; i++) {
    cin >> u >> v;
    d[u][v] = 1;
    d[v][u] = 1;
  }
  for (int k = (1), _b = (n); k <= _b; k++)
    for (int i = (1), _b = (n); i <= _b; i++)
      for (int j = (1), _b = (n); j <= _b; j++)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
  for (int k = (1), _b = (n * 5); k <= _b; k++) {
    for (int i = (1), _b = (n); i <= _b; i++)
      for (int j = (1), _b = (n); j <= _b; j++) {
        if (i == j) continue;
        if (a[i] < b[i] && a[j] > b[j]) {
          int c = min(b[i] - a[i], a[j] - b[j]);
          go(j, i, c);
        }
      }
  }
  for (int i = (1), _b = (n); i <= _b; i++)
    if (a[i] != b[i]) {
      cout << "NO";
      return 0;
    }
  cout << top << endl;
  for (int i = (1), _b = (top); i <= _b; i++)
    cout << res[i].i << ' ' << res[i].j << ' ' << res[i].d << endl;
  fclose(stdin);
  fclose(stdout);
  return 0;
}