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 unsigned int ooi = 1 << 30;
const long long ool = 1ll << 60;
const int Maxn = 330;
const int Maxm = 50505;
struct edges {
  int to, next;
  long long c;
  edges(int _to = 0, int _next = 0, long long _c = 0)
      : to(_to), next(_next), c(_c) {}
} edg[Maxm << 1];
int fir[Maxn] = {0}, tot = 1;
int v[Maxn] = {0}, cur[Maxn] = {0};
void Adde(int a, int b, long long c, long long nc = 0) {
  edg[++tot] = edges(b, fir[a], c);
  fir[a] = tot;
  edg[++tot] = edges(a, fir[b], nc);
  fir[b] = tot;
}
bool bfs(int st, int ed) {
  static queue<int> q;
  memset(v, 0, sizeof(v));
  q.push(st);
  v[st] = 1;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    for (int e = fir[now]; e; e = edg[e].next) {
      int to = edg[e].to;
      if (v[to] || !edg[e].c) continue;
      v[to] = v[now] + 1;
      q.push(to);
    }
  }
  return v[ed];
}
long long dfs(int now, int ed, long long dist = ool) {
  if (now == ed || !dist) return dist;
  long long f = 0;
  for (int &e = cur[now]; e; e = edg[e].next) {
    int to = edg[e].to;
    if (!edg[e].c || v[to] != v[now] + 1) continue;
    long long tmp = dfs(to, ed, min(dist, edg[e].c));
    if (tmp) {
      f += tmp;
      edg[e].c -= tmp;
      edg[e ^ 1].c += tmp;
      dist -= tmp;
      if (!dist) return f;
    }
  }
  return f;
}
long long dinic(int st, int ed, int nst, int ned) {
  long long re = 0;
  while (bfs(st, ed)) {
    for (int i = nst; i <= ned; i++) cur[i] = fir[i];
    while (long long d = dfs(st, ed)) re += d;
  }
  return re;
}
bool linked[Maxn][Maxn] = {0};
int stv[Maxn] = {0}, edv[Maxn] = {0};
int nowv[Maxn] = {0};
int ans[Maxn * Maxn * 3][3] = {0}, edans = 0;
int main() {
  int n, V, e;
  cin >> n >> V >> e;
  long long sumf = 0;
  for (int i = 1; i <= n; i++) cin >> stv[i];
  for (int i = 1; i <= n; i++) cin >> edv[i];
  for (int a, b, i = 1; i <= e; i++) {
    cin >> a >> b;
    if (a == b) continue;
    if (!linked[a][b]) {
      Adde(a, b, ool, ool);
      linked[a][b] = linked[b][a] = 1;
    }
  }
  int alledges = tot;
  int s = 0, t = n + 1;
  long long sum = 0;
  for (int i = 1; i <= n; i++) {
    nowv[i] = stv[i];
    int delta = edv[i] - stv[i];
    sum += delta;
    sumf += abs(delta);
    if (delta < 0)
      Adde(s, i, -delta);
    else if (delta > 0)
      Adde(i, t, delta);
  }
  if (sum) {
    cout << "NO" << endl;
    return 0;
  }
  if (sumf != 2 * dinic(s, t, s, t)) {
    cout << "NO" << endl;
    return 0;
  };
  while (true) {
    bool flag = 0;
    for (int e = 2; e <= alledges; e += 2) {
      if (edg[e].c == ool) continue;
      int b = edg[e].to, a = edg[e ^ 1].to;
      if (edg[e].c < ool) {
        if (!nowv[a] || nowv[b] == V) continue;
        int f = min((long long)min(nowv[a], V - nowv[b]), ool - edg[e].c);
        ans[++edans][0] = a;
        ans[edans][1] = b;
        ans[edans][2] = f;
        nowv[a] -= f;
        nowv[b] += f;
        edg[e].c += f;
        edg[e ^ 1].c -= f;
        flag = 1;
      } else {
        if (!nowv[b] || nowv[a] == V) continue;
        int f = min((long long)min(nowv[b], V - nowv[a]), edg[e].c - ool);
        ans[++edans][0] = b;
        ans[edans][1] = a;
        ans[edans][2] = f;
        nowv[b] -= f;
        nowv[a] += f;
        edg[e].c -= f;
        edg[e ^ 1].c += f;
        flag = 1;
      }
    }
    if (!flag) break;
    if (edans >= 2 * n * n) break;
  }
  for (int e = 2; e <= alledges; e += 2)
    if (edg[e].c != ool) {
      cout << "NO" << endl;
      return 0;
    }
  cout << edans << endl;
  for (int i = 1; i <= edans; i++)
    cout << ans[i][0] << " " << ans[i][1] << " " << ans[i][2] << endl;
  return 0;
}