Data Center Cooling#2093

Data Center Cooling

2 seconds
64 megabytes
Medium

A group of engineers is designing a new advanced data center. As the computer expert on this project, your role is to design the center's cooling system.

The cooling system consists of a set of pipes connecting nodes. Liquid flows through these pipes, and each pipe has a strictly defined direction in which the liquid should flow. The nodes in the cooling system are numbered from to . The system must be designed so that, for each node, the amount of liquid entering the node per unit time is equal to the amount exiting it. That is, if f_{ij} units of liquid flow from node to node per unit time (if there is no pipe from to , set f_{ij} = 0), then for each node the following condition must be satisfied:

Each pipe has a capacity c_{ij}. In addition, to ensure sufficient cooling, at least l_{ij} units of liquid must flow through each pipe per unit time. Thus, for the pipe from node to node , it must hold that l_{ij} \leq f_{ij} \leq c_{ij}.

You are given a description of the cooling system. Determine how the liquid can be directed through the pipes so that all the specified conditions are met.

Input

The first line of the input file contains the numbers and — the number of nodes and pipes (1 \leq N \leq 200). The next lines contain descriptions of the pipes. Each line contains four integers , , l_{ij}, and c_{ij}. Any two nodes are connected by at most one pipe; if there is a pipe from to , there is no pipe from to , and no node is connected to itself. The constraints are 0 \leq l_{ij} \leq c_{ij} \leq 10^5.

Output

If a solution exists, output the word YES on the first line of the output file. Then output numbers — 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.

Examples

Example 1

Loading
Loading