401879: GYM100551 E Disconnected Graph

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

E. Disconnected Graphtime limit per test3 secondsmemory limit per test256 megabytesinputdisconnected.inoutputdisconnected.out

You are given a connected undirected graph and several small sets of its edges. For each set, you need to determine whether the graph stays connected with edges from the set removed.

Remember that a graph is connected when for every two distinct vertices there's a path connecting them.

Input

The first line of the input file contains two integers n and m (1 ≤ n ≤ 10 000, 1 ≤ m ≤ 100 000), denoting the number of vertices and edges in the graph, respectively. Vertices are numbered from 1 to n.

The next m lines contain the description of the edges. Each line contains two integers a and b — the numbers of the vertices connected by this edge. Each pair of vertices is connected by at most one edge. No edge connects a vertex to itself. Edges are numbered from 1 to m in the order they are given in the input.

The next line contains an integer k (1 ≤ k ≤ 100 000), denoting the number of small sets to test. The next k lines contain the descriptions of the small sets. Each line starts with an integer c (1 ≤ c ≤ 4), denoting the number of edges in the set, followed by c numbers of the edges from the set. The numbers of the edges inside one small set will be distinct.

Output

Output k lines, one per each given small set. The i-th line should contain "Connected" (without quotes), if removal of the corresponding small set leaves the graph connected, or "Disconnected" otherwise.

ExamplesInput
4 5
1 2
2 3
3 4
4 1
2 4
3
1 5
2 2 3
2 1 2
Output
Connected
Disconnected
Connected

加入题单

算法标签: