{"problem":{"name":"Builder Takahashi","description":{"content":"We have a simple connected undirected graph with $N$ vertices and $M$ edges.   The vertices are numbered as Vertex $1$, Vertex $2$, $\\dots$, Vertex $N$.   The edges are numbered as Edge $1$, Edge $2$,","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc239_g"},"statements":[{"statement_type":"Markdown","content":"We have a simple connected undirected graph with $N$ vertices and $M$ edges.  \nThe vertices are numbered as Vertex $1$, Vertex $2$, $\\dots$, Vertex $N$.  \nThe edges are numbered as Edge $1$, Edge $2$, $\\dots$, Edge $M$. Edge $i$ connects Vertex $a_i$ and Vertex $b_i$ bidirectionally. There is no edge that directly connects Vertex $1$ and Vertex $N$.  \nEach vertex is either empty or occupied by a wall. Initially, every vertex is empty.\nAoki is going to travel from Vertex $1$ to Vertex $N$ along the edges on the graph. However, Aoki is not allowed to move to a vertex occupied by a wall.\nTakahashi has decided to choose some of the vertices to build walls on, so that Aoki cannot travel to Vertex $N$ no matter which route he takes.  \nBuilding a wall on Vertex $i$ costs Takahashi $c_i$ yen (the currency of Japan). **He cannot build a wall on Vertex $1$ and Vertex $N$**.\nHow many yens is required for Takahashi to build walls so that the conditions is satisfied? Also, print the way of building walls to achieve the minimum cost.\n\n## Constraints\n\n*   $3 \\leq N \\leq 100$\n*   $N - 1 \\leq M \\leq \\frac{N(N-1)}{2} - 1$\n*   $1 \\leq a_i \\lt b_i \\leq N$ $(1 \\leq i \\leq M)$\n*   $(a_i, b_i) \\neq (1, N)$\n*   The given graph is simple and connected.\n*   $1 \\leq c_{i} \\leq 10^9$ $(2 \\leq i \\leq N-1)$\n*   $c_1 = c_N = 0$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $M$\n$a_1$ $b_1$\n$a_2$ $b_2$\n$\\vdots$\n$a_M$ $b_M$\n$c_1$ $c_2$ $\\dots$ $c_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc239_g","tags":[],"sample_group":[["5 5\n1 2\n2 3\n3 5\n2 4\n4 5\n0 8 3 4 0","7\n2\n3 4\n\nIf Takahashi builds walls on Vertex $3$ and Vertex $4$, paying $3 + 4 = 7$ yen, Aoki is unable to travel from Vertex $1$ to Vertex $5$.  \nThere is no way to satisfy the condition with less cost, so $7$ yen is the answer."],["3 2\n1 2\n2 3\n0 1 0","1\n1\n2"],["5 9\n1 2\n1 3\n1 4\n2 3\n2 4\n2 5\n3 4\n3 5\n4 5\n0 1000000000 1000000000 1000000000 0","3000000000\n3\n2 3 4"]],"created_at":"2026-03-03 11:01:13"}}