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;
int V, E, C;
int a[310], b[310];
bool graph[310][310];
vector<int> tree[310];
bool vis[310];
int POST;
int post[310];
bool used[310];
int STEP;
int ans1[200000], ans2[200000], ans3[200000];
void dfs(int p, int x) {
  int i;
  vis[x] = true;
  for ((i) = 0; (i) < (int)(V); (i)++)
    if (graph[x][i] && !vis[i]) {
      dfs(x, i);
      tree[x].push_back(i);
      tree[i].push_back(x);
    }
  post[POST] = x;
  POST++;
}
int answer(int from, int to, int bound) {
  int f = min(bound, min(a[from], C - a[to]));
  ans1[STEP] = from;
  ans2[STEP] = to;
  ans3[STEP] = f;
  STEP++;
  a[from] -= f;
  a[to] += f;
  return f;
}
int dfs_out(int p, int x, int c) {
  if (used[p] || used[x]) return 0;
  int i;
  int step1 = answer(p, x, c);
  for ((i) = 0; (i) < (int)(tree[x].size()); (i)++) {
    int y = tree[x][i];
    if (y == p) continue;
    if (used[y]) continue;
    answer(x, y, C);
    dfs_out(x, y, C);
    answer(x, y, C);
  }
  int step2 = answer(p, x, c - step1);
  return step1 + step2;
}
int dfs_in(int p, int x, int c) {
  if (used[p] || used[x]) return 0;
  int i;
  int step1 = answer(x, p, c);
  for ((i) = 0; (i) < (int)(tree[x].size()); (i)++) {
    int y = tree[x][i];
    if (y == p) continue;
    if (used[y]) continue;
    answer(y, x, C);
    dfs_in(x, y, C);
    answer(y, x, C);
  }
  int step2 = answer(x, p, c - step1);
  return step1 + step2;
}
bool fix(int x) {
  int i;
  if (a[x] == b[x]) return true;
  if (a[x] > b[x]) {
    int c = a[x] - b[x];
    for ((i) = 0; (i) < (int)(tree[x].size()); (i)++) {
      int y = tree[x][i];
      int tmp = dfs_out(x, y, c);
      c -= tmp;
    }
    return (c == 0);
  }
  if (a[x] < b[x]) {
    int c = b[x] - a[x];
    for ((i) = 0; (i) < (int)(tree[x].size()); (i)++) {
      int y = tree[x][i];
      int tmp = dfs_in(x, y, c);
      c -= tmp;
    }
    return (c == 0);
  }
  return true;
}
int main(void) {
  int i, j;
  cin >> V >> C >> E;
  for ((i) = 0; (i) < (int)(V); (i)++) cin >> a[i];
  for ((i) = 0; (i) < (int)(V); (i)++) cin >> b[i];
  for ((i) = 0; (i) < (int)(E); (i)++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    graph[x][y] = graph[y][x] = true;
  }
  for ((i) = 0; (i) < (int)(V); (i)++)
    if (!vis[i]) dfs(-1, i);
  for ((i) = 0; (i) < (int)(V); (i)++) {
    if (!fix(post[i])) {
      cout << "NO" << endl;
      return 0;
    }
    used[post[i]] = true;
  }
  cout << STEP << endl;
  for ((i) = 0; (i) < (int)(STEP); (i)++)
    printf("%d %d %d\n", ans1[i] + 1, ans2[i] + 1, ans3[i]);
  return 0;
}