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 NMax = 400;
int G[NMax][NMax];
int N, V, E, A[NMax], B[NMax], father[NMax], father1[NMax];
vector<int> cur;
int Find(int a) {
  int R;
  for (R = a; father[R] != -1; R = father[R])
    ;
  return R;
}
int F[NMax], have[NMax];
int DFS(int a, int cnt) {
  int last = cnt;
  have[a] = 1;
  for (int i = 0; i < cur.size(); i++)
    if (!have[cur[i]] && father1[cur[i]] == -1 && G[a][cur[i]]) {
      father1[cur[i]] = a;
      int take = DFS(cur[i], cnt);
      cnt -= take;
    }
  if (A[a] < B[a]) {
    int take = min(cnt, B[a] - A[a]);
    cnt -= take;
    A[a] += take;
  }
  return F[a] = last - cnt;
}
vector<pair<pair<int, int>, int> > Q;
void getans(int a) {
  for (int i = 0; i < cur.size(); i++)
    if (father1[cur[i]] == a) {
      if (F[cur[i]] + A[cur[i]] <= V) {
        if (F[cur[i]] > 0)
          Q.push_back(make_pair(make_pair(a, cur[i]), F[cur[i]]));
        getans(cur[i]);
      }
    }
  for (int i = 0; i < cur.size(); i++)
    if (father1[cur[i]] == a) {
      if (F[cur[i]] + A[cur[i]] > V) {
        if (V - A[cur[i]] > 0)
          Q.push_back(make_pair(make_pair(a, cur[i]), V - A[cur[i]]));
        getans(cur[i]);
        if (F[cur[i]] - (V - A[cur[i]]) > 0)
          Q.push_back(
              make_pair(make_pair(a, cur[i]), F[cur[i]] - (V - A[cur[i]])));
      }
    }
}
int main() {
  memset(father, -1, sizeof(father));
  scanf("%d%d%d", &N, &V, &E);
  for (int i = 1; i <= N; i++) scanf("%d", A + i);
  for (int i = 1; i <= N; i++) scanf("%d", B + i);
  for (int i = 1; i <= E; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    G[x][y] = G[y][x] = 1;
    int x1 = Find(x), x2 = Find(y);
    if (x1 != x2) father[x1] = x2;
  }
  for (int i = 1; i <= N; i++)
    if (father[i] == -1) {
      long long cnta = 0, cntb = 0;
      cur.clear();
      for (int j = 1; j <= N; j++)
        if (Find(j) == i) {
          cur.push_back(j);
          cnta += A[j];
          cntb += B[j];
        }
      if (cnta != cntb) {
        puts("NO");
        return 0;
      }
      for (int j = 0; j < cur.size(); j++)
        if (A[cur[j]] > B[cur[j]]) {
          memset(have, 0, sizeof(have));
          memset(father1, -1, sizeof(father1));
          DFS(cur[j], A[cur[j]] - B[cur[j]]);
          getans(cur[j]);
          A[cur[j]] = B[cur[j]];
        }
    }
  printf("%d\n", (int)Q.size());
  for (int i = 0; i < Q.size(); i++)
    printf("%d %d %d\n", Q[i].first.first, Q[i].first.second, Q[i].second);
  return 0;
}