Reactor Cooling
A group of young scientists in a developing country has decided to construct a nuclear reactor to produce enriched plutonium. As the computer expert in this team, your role is to design the reactor's cooling system.
The cooling system is comprised of a network of pipes connecting various nodes. Liquid flows through these pipes, and each pipe has a predetermined flow direction. The nodes in the cooling system are numbered from 1 to N. The system must be configured so that, for every node, the volume of liquid entering the node per unit time is equal to the volume exiting it. Specifically, if f_ij units of liquid flow from node i to node j per unit time (with f_ij = 0 if there is no pipe from i to j), then for each node i, the following condition must be satisfied:
Each pipe has a capacity c_ij. Additionally, to ensure adequate cooling, at least l_ij units of liquid must flow through each pipe per unit time. Therefore, for the pipe from node i to node j, it must hold that l_ij ≤ f_ij ≤ c_ij.
You are provided with a description of the cooling system. Your task is to determine how the liquid can be directed through the pipes to meet all the specified conditions.
Input
The first line of the input file contains the numbers N and M – the number of nodes and pipes (1 ≤ N ≤ 200). The following M lines describe the pipes. Each line contains four integers i, j, l_ij, and c_ij. Any two nodes are connected by at most one pipe; if there is a pipe from i to j, there is no pipe from j to i, and no node is connected to itself by a pipe. The constraints are 0 ≤ l_{ij }≤ c_{ij }≤ 10^5.
Output
If a solution exists, output the word YES on the first line of the output file. Then, output M numbers representing the amount of liquid that should flow through each pipe, in the order the pipes are listed in the input file. If no solution exists, output NO.