{"trustable":true,"prependHtml":"\u003clink rel\u003dstylesheet href\u003d\u0027https://static.toph.co/css/katex.css\u0027\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eZer is a programmer who has a friend named Nir. Nir always shows off how great EEE is. One day Nir came to Zer with a EEE\u0027ish problem. Nir gave Zer a circuit. The circuit has \u003cstrong\u003eN\u003c/strong\u003e nodes and \u003cstrong\u003eM\u003c/strong\u003e wires where each wire connects two different nodes. Moreover, a wire that connects node \u003cstrong\u003eU\u003c/strong\u003e to node \u003cstrong\u003eV\u003c/strong\u003e can only pass electricity from \u003cstrong\u003eU\u003c/strong\u003e to \u003cstrong\u003eV\u003c/strong\u003e but not vice-versa, that means the wires are uni-directed.\u003c/p\u003e\u003cp\u003eNir gave Zer a list of these wires detailing which wire connects which nodes. There are also a lower bound and an upper bound for each wire describing the minimum amount of electricity that must pass through the wire and the maximum amount of electricity that can pass through the wire, respectively. Also, according to KCL (Kirchhoff\u0027s Circuit Law), the net amount of electricity entering a node must be equal to the net amount of electricity exiting that node.\u003c/p\u003e\u003cp\u003eZer has to give a valid configuration for the problem Nir gives. He has to tell the amount of electricity flowing through each wire such that all the above constraints are satisfied. As a good problem solver, your help would be highly appreciated by Zer.\u003c/p\u003e\u003ch2\u003eInput\u003c/h2\u003e\u003cp\u003eThe input starts with two integers \u003cstrong\u003eN\u003c/strong\u003e and \u003cstrong\u003eM\u003c/strong\u003e, the number of nodes and the number of wires respectively.\u003c/p\u003e\u003cp\u003eEach of the next \u003cstrong\u003eM\u003c/strong\u003e lines contains four integers \u003cstrong\u003eU\u003c/strong\u003e, \u003cstrong\u003eV\u003c/strong\u003e, \u003cstrong\u003eL\u003c/strong\u003e, \u003cstrong\u003eH\u003c/strong\u003e, stating that a wire connects node \u003cstrong\u003eU\u003c/strong\u003e and \u003cstrong\u003eV\u003c/strong\u003e such that electricity can pass from \u003cstrong\u003eU\u003c/strong\u003e to \u003cstrong\u003eV\u003c/strong\u003e and the amount of electricity must be at least \u003cstrong\u003eL\u003c/strong\u003e and at most \u003cstrong\u003eH\u003c/strong\u003e.\u003c/p\u003e\u003cp\u003eIt is guaranteed that no two wires will have exactly the same \u003cstrong\u003eU\u003c/strong\u003e and \u003cstrong\u003eV\u003c/strong\u003e i.e. there will be at most one wire that allows electricity to pass from a node \u003cstrong\u003eU\u003c/strong\u003e to another node \u003cstrong\u003eV\u003c/strong\u003e.\u003c/p\u003e\u003cp\u003e\u003cstrong\u003eConstraints\u003c/strong\u003e:\u003cbr\u003e1 ≤ N ≤ 100\u003cbr\u003eFor each wire,\u003cbr\u003e1 ≤ U, V ≤ N\u003cbr\u003eU !\u003d V\u003cbr\u003e0 ≤ L ≤ H ≤ 106\u003c/p\u003e\u003ch2\u003eOutput\u003c/h2\u003e\u003cp\u003eIf no valid configuration exists, print \u003cstrong\u003eNO\u003c/strong\u003e in a single line.\u003c/p\u003e\u003cp\u003eOtherwise, print \u003cstrong\u003eYES\u003c/strong\u003e followed by \u003cstrong\u003eM\u003c/strong\u003e lines. Each line should contain the amount of electricity flowing through each wire in the same order as given in input.\u003c/p\u003e\u003cp\u003eIf multiple valid configurations exist, print any of them in such a case.\u003c/p\u003e\u003ch2\u003eSamples\u003c/h2\u003e\u003cdiv class\u003d\"tablebox\"\u003e\u003ctable class\u003d\"-samples vjudge_sample\"\u003e\u003cthead\u003e\u003ctr\u003e\u003cth style\u003d\"width:50%\"\u003eInput\u003c/th\u003e\u003cth style\u003d\"width:50%\"\u003eOutput\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"pre copywrap\"\u003e\u003cpre id\u003d\"preSample0Input\"\u003e3 3\n1 2 1 2\n2 3 0 3\n3 1 2 6\u003c/pre\u003e\u003c/td\u003e\u003ctd class\u003d\"pre copywrap\"\u003e\u003cpre id\u003d\"preSample0Output\"\u003eYES\n2\n2\n2\n\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003ctable class\u003d\"-samples vjudge_sample\"\u003e\u003cthead\u003e\u003ctr\u003e\u003cth style\u003d\"width:50%\"\u003eInput\u003c/th\u003e\u003cth style\u003d\"width:50%\"\u003eOutput\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"pre copywrap\"\u003e\u003cpre id\u003d\"preSample1Input\"\u003e3 3\n1 2 1 2\n2 3 0 3\n3 1 4 5\u003c/pre\u003e\u003c/td\u003e\u003ctd class\u003d\"pre copywrap\"\u003e\u003cpre id\u003d\"preSample1Output\"\u003eNO\n\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003ctable class\u003d\"-samples vjudge_sample\"\u003e\u003cthead\u003e\u003ctr\u003e\u003cth style\u003d\"width:50%\"\u003eInput\u003c/th\u003e\u003cth style\u003d\"width:50%\"\u003eOutput\u003c/th\u003e\u003c/tr\u003e\u003c/thead\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"pre copywrap\"\u003e\u003cpre id\u003d\"preSample2Input\"\u003e4 5\n1 2 1 2\n2 3 0 3\n3 1 2 6\n3 4 1 1\n4 3 1 1\u003c/pre\u003e\u003c/td\u003e\u003ctd class\u003d\"pre copywrap\"\u003e\u003cpre id\u003d\"preSample2Output\"\u003eYES\n2\n2\n2\n1\n1\n\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/div\u003e\u003cbr\u003e"}}]}