{"problem":{"name":"Unique Walk","description":{"content":"You are given a simple connected undirected graph $G$ with $N$ vertices and $M$ edges.   The vertices of $G$ are numbered vertex $1$, vertex $2$, $\\ldots$, and vertex $N$, and its edges are numbered e","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc286_g"},"statements":[{"statement_type":"Markdown","content":"You are given a simple connected undirected graph $G$ with $N$ vertices and $M$ edges.  \nThe vertices of $G$ are numbered vertex $1$, vertex $2$, $\\ldots$, and vertex $N$, and its edges are numbered edge $1$, edge $2$, $\\ldots$, and edge $M$. Edge $i$ connects vertex $U_i$ and vertex $V_i$.  \nYou are also given a subset of the edges: $S={x_1,x_2,\\ldots,x_K}$.\nDetermine if there is a walk on $G$ that contains edge $x$ exactly once for all $x \\in S$.  \nThe walk may contain an edge not in $S$ any number of times (possibly zero).\nWhat is a walk? A walk on an undirected graph $G$ is a sequence consisting of $k$ vertices ($k$ is a positive integer) and $(k-1)$ edges occurring alternately, $v_1,e_1,v_2,\\ldots,v_{k-1},e_{k-1},v_k$, such that edge $e_i$ connects vertex $v_i$ and vertex $v_{i+1}$. The sequence may contain the same edge or vertex multiple times. A walk is said to contain an edge $x$ exactly once if and only if there is exactly one $1\\leq i\\leq k-1$ such that $e_i=x$.\n\n## Constraints\n\n*   $2 \\leq N \\leq 2\\times 10^5$\n*   $N-1 \\leq M \\leq \\min(\\frac{N(N-1)}{2},2\\times 10^5)$\n*   $1 \\leq U_i<V_i\\leq N$\n*   If $i\\neq j$, then $(U_i,V_i)\\neq (U_j,V_j)$ .\n*   $G$ is connected.\n*   $1 \\leq K \\leq M$\n*   $1 \\leq x_1<x_2<\\cdots<x_K \\leq M$\n*   All values in the input are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $M$\n$U_1$ $V_1$\n$U_2$ $V_2$\n$\\vdots$\n$U_M$ $V_M$\n$K$\n$x_1$ $x_2$ $\\ldots$ $x_K$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc286_g","tags":[],"sample_group":[["6 6\n1 3\n2 3\n3 4\n4 5\n4 6\n5 6\n4\n1 2 4 5","Yes\n\nThe walk $(v_1,e_1,v_3,e_3,v_4,e_4,v_5,e_6,v_6,e_5,v_4,e_3,v_3,e_2,v_2)$ satisfies the condition, where $v_i$ denotes vertex $i$ and $e_i$ denotes edge $i$.  \nIn other words, the walk travels the vertices on $G$ in this order: $1\\to 3\\to 4\\to 5\\to 6\\to 4\\to 3\\to 2$.  \nThis walk satisfies the condition because it contains edges $1$, $2$, $4$, and $5$ exactly once each."],["6 5\n1 2\n1 3\n1 4\n1 5\n1 6\n3\n1 2 3","No\n\nThere is no walk that contains edges $1$, $2$, and $3$ exactly once each, so `No` should be printed."]],"created_at":"2026-03-03 11:01:14"}}