QOJ.ac

QOJ

Time Limit: 5 s Memory Limit: 2048 MB Total points: 100 Open Tests

#5413. Isomorphism Judgment Chicken

Statistics

The Peking University Catering Complex has opened!

Little F is a knowledgeable chicken. To avoid being cooked in the hot pot on the fourth floor of the complex, it intends to demonstrate some skills to the foolish humans.

There are a total of $T$ queries from humans. Each query provides a graph $H=(V_H, E_H)$ with $n$ vertices and $m$ edges. Little F, the isomorphism-judging chicken, will respond with a graph $G=(V_G, E_G)$ for each query, satisfying the following conditions:

  1. The number of vertices $|V_G| \le N$.
  2. The number of edges $|E_G| \ge M$.
  3. $H$ is not a subgraph of $G$, meaning it is impossible to obtain $H$ by deleting vertices and edges from $G$ and relabeling them.

The humans are unaware of Little F's superior graph isomorphism skills, so the given graph $H$ will satisfy some special properties (see Constraints).

Little F thinks this problem is too simple, so it has handed the problem over to you.

Input

The first line contains two non-negative integers $T$ and $type$, representing the number of test cases and the test point index. If $type=0$, it indicates that the data is a sample and will not appear in the evaluation dataset. That is, for all evaluation data, $1 \le type \le 6$.

For each test case, the first line contains two non-negative integers $n$ and $m$, with the same meanings as in the problem description.

The next $m$ lines each contain two integers $u_i, v_i$, representing an edge in graph $H$. It is guaranteed that there are no multiple edges or self-loops.

The last line contains two integers $N$ and $M$, representing the constraints on the number of vertices and edges of graph $G$.

Output

For each test case, the first line contains two positive integers $n'$ and $m'$, representing the number of vertices and edges of the graph $G$ you constructed.

Then, $m'$ lines follow, each containing two positive integers $x_i, y_i$, representing an edge in graph $G$.

You must ensure that there are no multiple edges or self-loops in graph $G$, otherwise your answer will be judged as incorrect.

Examples

Input 1

1 0
4 3
1 2
1 3
3 4
4 0

Output 1

4 0

Note 1

Obviously, $H$ is not a subgraph of the empty graph $G$.

Constraints

There are 6 test points in total. The information for each test point is as follows:

Test points 1 to 4 are evaluated using special judge 1. The output must fully satisfy the problem conditions to receive full marks.

Test point 1 ($5\%$): $H$ is a complete graph with $3$ vertices; $N \le 100$, $M = [N^2/4]$. $[]$ denotes the floor function, as used below.

Test point 2 ($10\%$): $H$ is a complete graph, and $n \le 10$; $n \le N \le 100$, $M = \left[\left(1-\frac1{n-1}\right) \cdot N^2/2\right]-1$.

Test point 3 ($10\%$): $H$ is $K(2, 2)$ (a complete bipartite graph with $2$ vertices on the left and $2$ on the right, same below); $50 \le N \le 2000$, $M = 2N$.

Test point 4 ($15\%$): $H$ is $K(2, 2)$; $N \le 2000$, and $N$ can be expressed as the square of an odd prime, $M = [N(\sqrt N-1)/2]$.

Test points 5 and 6 satisfy $T=1$ and are evaluated using special judge 2. The output must fully satisfy the problem conditions to receive points. Assuming the number of edges in your proposed solution is $m'$, the score for your program is $\left\lfloor 30\times\left(1-0.5\left(\frac{3M}{m'}-1\right)\right)\right\rfloor$. That is, only solutions with $m' \ge 3M$ can receive full marks.

Test point 5 ($30\%$): $H$ is $K(2, 2)$; $N=2850$, $M=24300$, $3M=72\,900$.

Test point 6 ($30\%$): $H$ is $K(3, 3)$; $N = 343 = 7^3$, $M=2350$, $3M=7050$.

For all test points, $1 \le T \le 10$ and $N \ge n > 2$.

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.