{"trustable":true,"prependHtml":"\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eThe terrorist group leaded by a well known international terrorist Ben Bladen is buliding a nuclear\nreactor to produce plutonium for the nuclear bomb they are planning to create. Being the wicked\ncomputer genius of this group, you are responsible for developing the cooling system for the reactor.\u003c/p\u003e\n\n\u003cp\u003eThe cooling system of the reactor consists of the number of pipes that special cooling liquid flows by.\nPipes are connected at special points, called nodes, each pipe has the starting node and the end point.\nThe liquid must flow by the pipe from its start point to its end point and not in the opposite direction.\u003c/p\u003e\n\n\u003cp\u003eLet the nodes be numbered from 1 to N. The cooling system must be designed so that the liquid is\ncirculating by the pipes and the amount of the liquid coming to each node (in the unit of time) is equal\nto the amount of liquid leaving the node. That is, if we designate the amount of liquid going by the\npipe from i-th node to j-th as f\u003csub\u003eij\u003c/sub\u003e, (put f\u003csub\u003eij\u003c/sub\u003e \u003d 0 if there is no pipe from node i to node j), for each i the\nfollowing condition must hold:\u003c/p\u003e\n\n\u003ccenter\u003e\nf\u003csub\u003ei,1\u003c/sub\u003e+f\u003csub\u003ei,2\u003c/sub\u003e+...+f\u003csub\u003ei,N\u003c/sub\u003e \u003d f\u003csub\u003e1,i\u003c/sub\u003e+f\u003csub\u003e2,i\u003c/sub\u003e+...+f\u003csub\u003eN,i\u003c/sub\u003e\n\u003c/center\u003e\n\n\u003cp\u003eEach pipe has some finite capacity, therefore for each i and j connected by the pipe must be f\u003csub\u003eij\u003c/sub\u003e \u0026lt;\u003d c\u003csub\u003eij\u003c/sub\u003e\nwhere cij is the capacity of the pipe. To provide sufficient cooling, the amount of the liquid flowing by\nthe pipe going from i-th to j-th nodes must be at least l\u003csub\u003eij\u003c/sub\u003e, thus it must be f\u003csub\u003eij\u003c/sub\u003e \u0026gt;\u003d l\u003csub\u003eij\u003c/sub\u003e.\u003c/p\u003e\n\u003cp\u003eGiven cij and l\u003csub\u003eij\u003c/sub\u003e for all pipes, find the amount f\u003csub\u003eij\u003c/sub\u003e, satisfying the conditions specified above.\u003c/p\u003e\n\n\u003cbr\u003e\n\u003cb\u003e\u003cp\u003eThis problem contains multiple test cases!\u003c/p\u003e\u003c/b\u003e\n\u003cp\u003eThe first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.\u003c/p\u003e\n\u003cp\u003eThe output format consists of N output blocks. There is a blank line between output blocks.\u003c/p\u003e\n\n\u003cbr\u003e\n\u003cp\u003e\u003cb\u003eInput\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eThe first line of the input file contains the number N (1 \u0026lt;\u003d N \u0026lt;\u003d 200) - the number of nodes and and\nM - the number of pipes. The following M lines contain four integer number each - i, j, lij and cij\neach. There is at most one pipe connecting any two nodes and 0 \u0026lt;\u003d l\u003csub\u003eij\u003c/sub\u003e \u0026lt;\u003d c\u003csub\u003eij\u003c/sub\u003e \u0026lt;\u003d 10^5 for all pipes. No pipe\nconnects a node to itself. If there is a pipe from i-th node to j-th, there is no pipe from j-th node to i-th.\u003c/p\u003e\n\n\u003cbr\u003e\n\u003cp\u003e\u003cb\u003eOutput\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003eOn the first line of the output file print YES if there is the way to carry out reactor cooling and NO if\nthere is none. In the first case M integers must follow, k-th number being the amount of liquid flowing\nby the k-th pipe. Pipes are numbered as they are given in the input file.\u003c/p\u003e\n\n\u003cbr\u003e\n\u003cp\u003e\u003cb\u003eSample Input\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e\n2\u003cbr\u003e\n\u003cbr\u003e\n4 6\u003cbr\u003e\n1 2 1 2\u003cbr\u003e\n2 3 1 2\u003cbr\u003e\n3 4 1 2\u003cbr\u003e\n4 1 1 2\u003cbr\u003e\n1 3 1 2\u003cbr\u003e\n4 2 1 2\u003cbr\u003e\n\u003cbr\u003e\n4 6\u003cbr\u003e\n1 2 1 3\u003cbr\u003e\n2 3 1 3\u003cbr\u003e\n3 4 1 3\u003cbr\u003e\n4 1 1 3\u003cbr\u003e\n1 3 1 3\u003cbr\u003e\n4 2 1 3\u003cbr\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n\u003cp\u003e\u003cb\u003eSample Input\u003c/b\u003e\u003c/p\u003e\n\u003cp\u003e\nNO\u003cbr\u003e\n\u003cbr\u003e\nYES\u003cbr\u003e\n1\u003cbr\u003e\n2\u003cbr\u003e\n3\u003cbr\u003e\n2\u003cbr\u003e\n1\u003cbr\u003e\n1\u003cbr\u003e\n\u003c/p\u003e\n\n\u003cbr\u003e\n"}}]}