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;
#pragma comment(linker, "/STACK:100000000")
int n, v, e;
int mas[333][2];
vector<int> all[333];
set<int> st[333];
int comp[333];
vector<pair<pair<int, int>, int> > ans;
void go(int s, int c) {
  comp[s] = c;
  for (int i = 0, maxi = (int)(all[s]).size(); i < maxi; i++) {
    int t = all[s][i];
    if (comp[t] == 0) {
      st[t].insert(s);
      st[s].insert(t);
      go(t, c);
    }
  }
}
void push(int s, int val, int last) {
  long long sum = 0;
  set<int>::iterator it = st[s].begin();
  while (it != st[s].end()) {
    if (*it == last) {
      it++;
      continue;
    }
    sum += (long long)v - (long long)mas[*it][0];
    it++;
  }
  if (sum < (long long)val) {
    it = st[s].begin();
    while (it != st[s].end()) {
      if (*it == last) {
        it++;
        continue;
      }
      push(*it, (int)val - sum, s);
      it++;
    }
  }
  it = st[s].begin();
  while (it != st[s].end()) {
    if (*it == last) {
      it++;
      continue;
    }
    int cur = mas[*it][0];
    if (v - cur >= val) {
      mas[s][0] -= val;
      mas[*it][0] += val;
      cur -= val;
      ans.push_back(make_pair(make_pair(s, *it), val));
      break;
    } else {
      mas[*it][0] = v;
      val -= (v - cur);
      mas[s][0] -= (v - cur);
      ans.push_back(make_pair(make_pair(s, *it), v - cur));
    }
    it++;
  }
}
void get(int s, int val, int last) {
  long long sum = 0;
  set<int>::iterator it = st[s].begin();
  while (it != st[s].end()) {
    if (*it == last) {
      it++;
      continue;
    }
    sum += (long long)mas[*it][0];
    it++;
  }
  if (sum < (long long)val) {
    it = st[s].begin();
    while (it != st[s].end()) {
      if (*it == last) {
        it++;
        continue;
      }
      get(*it, (int)val - sum, s);
      it++;
    }
  }
  it = st[s].begin();
  while (it != st[s].end()) {
    if (*it == last) {
      it++;
      continue;
    }
    int cur = mas[*it][0];
    if (cur >= val) {
      mas[s][0] += val;
      mas[*it][0] -= val;
      cur -= val;
      ans.push_back(make_pair(make_pair(*it, s), val));
      break;
    } else {
      mas[*it][0] = 0;
      val -= cur;
      mas[s][0] += cur;
      ans.push_back(make_pair(make_pair(*it, s), cur));
    }
    it++;
  }
}
int main() {
  scanf("%d %d %d", &n, &v, &e);
  for (int i = 0; i < n; i++) scanf("%d", &mas[i][0]);
  for (int i = 0; i < n; i++) scanf("%d", &mas[i][1]);
  for (int i = 0; i < e; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    a--;
    b--;
    all[a].push_back(b);
    all[b].push_back(a);
  }
  int c = 1;
  for (int i = 0; i < n; i++) {
    if (comp[i] == 0) {
      go(i, c);
      c++;
    }
  }
  for (int i = 1; i < c; i++) {
    long long sum = 0;
    long long needsum = 0;
    for (int j = 0; j < n; j++) {
      if (comp[j] == i) {
        sum += (long long)mas[j][0];
        needsum += (long long)mas[j][1];
      }
    }
    if (sum != needsum) {
      printf("NO\n");
      return 0;
    }
  }
  int ost = n;
  while (ost) {
    ost = 0;
    for (int i = 0; i < n; i++) {
      if ((int)(st[i]).size() != 0) ost++;
      if ((int)(st[i]).size() == 1) {
        if (mas[i][0] < mas[i][1])
          get(i, mas[i][1] - mas[i][0], -1);
        else if (mas[i][0] > mas[i][1])
          push(i, mas[i][0] - mas[i][1], -1);
        st[*(st[i].begin())].erase(i);
        st[i].clear();
      }
    }
  }
  int len = (int)(ans).size();
  printf("%d\n", len);
  for (int i = 0; i < len; i++) {
    printf("%d %d %d\n", ans[i].first.first + 1, ans[i].first.second + 1,
           ans[i].second);
  }
  return 0;
}