{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"Alice and Bob play the following game. First, Alice draws some directed graph with N vertices and M arcs. After that Bob tries to destroy it. In a move he may take any vertex of the graph and remove either all arcs incoming into this vertex, or all arcs outgoing from this vertex. \r\u003cbr\u003eAlice assigns two costs to each vertex: Wi\u003csup\u003e+\u003c/sup\u003e and Wi\u003csup\u003e-\u003c/sup\u003e. If Bob removes all arcs incoming into the i-th vertex he pays Wi\u003csup\u003e+\u003c/sup\u003e dollars to Alice, and if he removes outgoing arcs he pays Wi\u003csup\u003e-\u003c/sup\u003e dollars. \r\u003cbr\u003eFind out what minimal sum Bob needs to remove all arcs from the graph. "}},{"title":"Input","value":{"format":"HTML","content":"Input file describes the graph Alice has drawn. The first line of the input file contains N and M (1 \u0026lt;\u003d N \u0026lt;\u003d 100, 1 \u0026lt;\u003d M \u0026lt;\u003d 5000). The second line contains N integer numbers specifying Wi\u003csup\u003e+\u003c/sup\u003e. The third line defines Wi\u003csup\u003e-\u003c/sup\u003e in a similar way. All costs are positive and do not exceed 10\u003csup\u003e6\u003c/sup\u003e . Each of the following M lines contains two integers describing the corresponding arc of the graph. Graph may contain loops and parallel arcs. "}},{"title":"Output","value":{"format":"HTML","content":"On the first line of the output file print W --- the minimal sum Bob must have to remove all arcs from the graph. On the second line print K --- the number of moves Bob needs to do it. After that print K lines that describe Bob\u0027s moves. Each line must first contain the number of the vertex and then \u0027+\u0027 or \u0027-\u0027 character, separated by one space. Character \u0027+\u0027 means that Bob removes all arcs incoming into the specified vertex and \u0027-\u0027 that Bob removes all arcs outgoing from the specified vertex. "}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3 6\r\n1 2 3\r\n4 2 1\r\n1 2\r\n1 1\r\n3 2\r\n1 2\r\n3 1\r\n2 3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e5\r\n3\r\n1 +\r\n2 -\r\n2 +\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}