func_code_string: #include <bits/stdc++.h>   using namespace std;   const long MAX_N = 1e3 + 1;   long n, m, h;   long aw[MAX_N];   long bw[MAX_N];   vector<long> g[MAX_N];   bool v[MAX_N];   vector<long> st;   vector<pair<pair<long, long>, long> > ans;   void add_edge(long a, long b) {     g[a].push_back(b);     g[b].push_back(a);   }   void try_flow(long i, long need) {     if (i + 1 >= st.size()) return;     long a = st[i], b = st[i + 1];     long can = min(need, h - aw[b]);     if (can > 0) {       ans.push_back(make_pair(make_pair(a, b), can));     }     try_flow(i + 1, need);     if (need - can > 0) {       ans.push_back(make_pair(make_pair(a, b), need - can));     }   }   void flow() {     long a = st[0];     long b = st[st.size() - 1];     long need = min(aw[a] - bw[a], bw[b] - aw[b]);     if (need > 0) {       try_flow(0, need);       aw[a] -= need;       aw[b] += need;     }   }   void dfs(long a) {     v[a] = true;     st.push_back(a);     if (aw[a] < bw[a]) flow();     for (size_t i = 0; i < g[a].size(); i++) {       long b = g[a][i];       if (!v[b]) dfs(b);     }     st.pop_back();   }   int main() {     cin >> n >> h >> m;     for (long i = 1; i <= n; i++) {       cin >> aw[i];     }     for (long i = 1; i <= n; i++) {       cin >> bw[i];     }     for (long i = 1; i <= m; i++) {       long x, y;       cin >> x >> y;       add_edge(x, y);     }     for (long i = 1; i <= n; i++) {       if (aw[i] > bw[i]) {         for (long j = 1; j <= n; j++) v[j] = false;         dfs(i);       }     }     for (long i = 1; i <= n; i++) {       if (aw[i] != bw[i]) {         cout <<  NO ;         return 0;       }     }     cout << ans.size() << endl;     for (size_t i = 0; i < ans.size(); i++) {       cout << ans[i].first.first <<     << ans[i].first.second <<                << ans[i].second << endl;     }     return 0;   }   