P14578 [Template] Feasible Flow with Lower and Upper Bounds (No Source or Sink)
Description
You are given a directed graph $G$ with $n$ vertices and $m$ directed edges. Each edge has a lower flow bound $l_i$ and an upper flow bound $r_i$.
You need to determine whether there exists a plan such that the flow $w_i$ of every edge satisfies the flow restriction $l_i\leq w_i\leq r_i$, and the flow is balanced at every vertex, that is, the incoming flow equals the outgoing flow at every vertex.
Construct a set of flows satisfying the above restrictions, or report that no solution exists.
Input Format
The first line contains two positive integers $n,m$, representing the number of vertices and the number of edges of the graph $G$.
The following $m$ lines each contain four non-negative integers $u_i,v_i,l_i,r_i$, representing the starting point and the ending point of each directed edge, as well as its lower flow bound and upper flow bound.
The graph may contain multiple edges and self-loops.
Output Format
If a feasible plan exists, output `Yes` on the first line, and then $m$ lines each containing one non-negative integer $w_i$, representing the actual flow of the $i$-th edge.
If no feasible plan exists, output `No`.
Explanation/Hint
### Example 1 Explanation

The figure shows the flow plan given in the sample output.
### Constraints
The graph may contain multiple edges and self-loops.
For all test data: $1\leq n\leq 10^3$, $1\leq m\leq 10^4$, $1\leq u_i,v_i\leq n$, $0\leq l_i\leq r_i\leq 10^5$.
Translated by QwenWork