QOJ.ac

QOJ

Límite de tiempo: 2 s Límite de memoria: 512 MB Puntuación total: 100

#8160. Cutting

Estadísticas

You are given an undirected connected graph with $n$ vertices and $m$ edges, containing no multiple edges or self-loops.

ymqOAO has $k$ queries. For each query, determine if the graph remains connected after removing $c_i$ specific edges.

Note: Queries are independent, meaning the removal of edges in one query does not affect subsequent queries.

Definition: * Connected graph: A graph in which there is a path between any two vertices.

Input

The first line contains two integers $n$ and $m$.

The next $m$ lines each contain two positive integers $x_i, y_i$, representing the $i$-th edge connecting $x_i$ and $y_i$.

The next line contains an integer $k$, representing the number of queries.

The next $k$ lines each describe a query: the first integer $c_i$ is the number of edges to be removed, followed by $c_i$ ($1 \le c_i \le 4$) integers representing the indices of the edges to be removed. The edge indices are in the range $[1, m]$.

Output

For each query, if the graph is not connected, output 'Bob'; otherwise, output 'ymqOAO'. (Do not include the quotes.)

Examples

Input 1

4 5
1 2
2 3
3 4
4 1
2 4
3
1 5
2 2 3
2 1 2

Output 1

ymqOAO
Bob
ymqOAO

Constraints

  • For 10% of the data, $1 \le m, n, k \le 2000$.
  • For another 10% of the data, $m = n - 1$.
  • For another 10% of the data, $c_i = 1$.
  • For 60% of the data, $1 \le m, n, k \le 10^5$.
  • For 100% of the data, $1 \le m, n, k \le 10^6$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.