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 Inf = 1e9;
const int N = 301;
vector<int> adj[N], g[N];
vector<pair<pair<int, int>, int> > ans;
int a[N], b[N], n, V, e;
int par[N][N];
bool vis[N], dd[N];
void input() {
  scanf("%d %d %d", &n, &V, &e);
  for (int i = 0; i < n; i++) scanf("%d", a + i);
  for (int i = 0; i < n; i++) scanf("%d", b + i);
  for (int i = 0; i < e; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
}
void dfs(int v) {
  vis[v] = true;
  for (int i = 0; i < adj[v].size(); i++)
    if (!vis[adj[v][i]]) {
      dfs(adj[v][i]);
      g[v].push_back(adj[v][i]);
      g[adj[v][i]].push_back(v);
    }
}
void give(int u, int v, int F, int W) {
  int w = min(W, F - a[v]);
  if (w == 0) return;
  a[u] -= w;
  a[v] += w;
  ans.push_back(pair<pair<int, int>, int>(pair<int, int>(u, v), w));
}
void deliver(int sc, int v, int dad) {
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i] != dad && !dd[g[v][i]]) deliver(sc, g[v][i], v);
  if (dad != sc)
    give(v, dad, V, a[v]);
  else if (v != sc)
    give(v, dad, b[dad], a[v]);
}
void leave(int v, int dad) {
  for (int i = 0; i < g[v].size(); i++)
    if (g[v][i] != dad && !dd[g[v][i]]) {
      leave(g[v][i], v);
      if (v != dad)
        give(v, g[v][i], V, a[v]);
      else
        give(v, g[v][i], V, a[v] - b[v]);
    }
}
void make() {
  for (int i = 0; i < n; i++)
    if (!vis[i]) dfs(i);
  for (int i = 0; i < n - 1; i++) {
    int c = 0;
    for (int j = 1; j < n; j++)
      if (g[j].size() == 1) c = j;
    if (c == 0) continue;
    if (b[c] > a[c])
      deliver(c, c, c);
    else
      leave(c, c);
    dd[c] = true;
    int par = g[c].back();
    g[c].clear();
    for (int j = 0; j < g[par].size(); j++)
      if (g[par][j] == c)
        g[par].erase(g[par].begin() + j, g[par].begin() + j + 1);
  }
}
int main() {
  input();
  make();
  for (int i = 0; i < n; i++)
    if (a[i] != b[i]) {
      printf("NO");
      exit(0);
    }
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); i++)
    printf("%d %d %d \n", ans[i].first.first + 1, ans[i].first.second + 1,
           ans[i].second);
}