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 sk[305];
long long sum_sk[305];
bool is_path[305][305];
int nx[305][305];
int current[305];
int desired[305];
int n, volume, m;
vector<int> x;
vector<int> y;
vector<int> d;
void dom(int a, int b, int c) {
  x.push_back(a);
  y.push_back(b);
  d.push_back(c);
  current[a] -= c;
  current[b] += c;
}
void move(vector<int>& v, int l, int r, int val) {
  if (l + 1 == r) {
    dom(v[l], v[r], val);
    return;
  }
  if (current[v[r - 1]] >= val) {
    dom(v[r - 1], v[r], val);
    move(v, l, r - 1, val);
  } else {
    dom(v[r - 1], v[r], current[v[r - 1]]);
    move(v, l, r - 1, val);
    dom(v[r - 1], v[r], val - desired[v[r - 1]]);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> volume >> m;
  for (int i = 1; i <= n; ++i) {
    cin >> current[i];
  }
  for (int i = 1; i <= n; ++i) {
    cin >> desired[i];
  }
  for (int i = 1; i <= n; ++i) {
    is_path[i][i] = true;
  }
  memset(nx, -1, sizeof(nx));
  for (int i = 1; i <= m; ++i) {
    int x, y;
    cin >> x >> y;
    is_path[x][y] = true;
    nx[x][y] = y;
    is_path[y][x] = true;
    nx[y][x] = x;
  }
  for (int k = 1; k <= n; ++k) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (!is_path[i][j] && is_path[i][k] && is_path[k][j]) {
          is_path[i][j] = true;
          nx[i][j] = nx[i][k];
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    sk[i] = 1;
    while (!is_path[i][sk[i]]) {
      ++sk[i];
    }
    sum_sk[sk[i]] += current[i] - desired[i];
  }
  for (int i = 1; i <= n; ++i) {
    if (sum_sk[i] != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  while (true) {
    int l = 1;
    while (l <= n && current[l] <= desired[l]) {
      ++l;
    }
    if (l > n) {
      break;
    }
    int r = 1;
    while (!is_path[l][r] || current[r] >= desired[r]) {
      ++r;
    }
    vector<int> path;
    for (int c = l; c != -1; c = nx[c][r]) {
      path.push_back(c);
    }
    for (int i = (int)path.size() - 1;; --i) {
      if (current[path[i]] > desired[path[i]]) {
        l = i;
        break;
      }
    }
    for (int i = l;; ++i) {
      if (current[path[i]] < desired[path[i]]) {
        r = i;
        break;
      }
    }
    int transferred = min(current[path[l]] - desired[path[l]],
                          desired[path[r]] - current[path[r]]);
    move(path, l, r, transferred);
  }
  cout << x.size() << endl;
  for (int i = 0; i < (int)x.size(); ++i) {
    cout << x[i] << " " << y[i] << " " << d[i] << "\n";
  }
}