Datasets:

Modalities:
Image
Text
Formats:
parquet
Size:
< 1K
Tags:
code
Libraries:
Datasets
pandas
License:
hackercup / 2023 /round3 /spooky_splits.md
wjomlex's picture
2023 Problems
ff444f7 verified
|
raw
history blame
1.91 kB

Mrs. Puff is taking her class trick-or-treating! Her (N) students, numbered from (1) to (N), are dressed up in spooky outfits and ready to collect some candy. To divide and conquer every house in Bikini Bottom, she would like to break up the class into equal-sized groups.

(M) pairs of students have similar-themed costumes that amplify their spookiness, the (i)th being students (A_i) and (B_i). Ms. Puff's would like to know: for which values of (K) can the class be divided into (K) groups of equal size without splitting up any of these pairs?

Constraints

(1 \leq T \leq 75) (2 \leq N \leq 100) (0 \leq M \leq \frac{N(N-1)}{2}) (1 \leq A_i, B_i \leq N) (A_i \neq B_i)

Each unordered pair of employees occurs at most once in a given test case.

Input Format

Input begins with an integer (T), the number of test cases. Each case begins with a line containing the two integers (N) and (M). Then, (M) lines follow, the (i)th of which contains the two integers (A_i) and (B_i).

Output Format

For the (i)th test case, print "Case #i: " followed by all possible values of (K) in ascending order, separated by spaces.

Sample Explanation

In the first sample case, there are three possible values of (K). Here's a possible arrangement:

  • (K = 1): All students can be put into a single group.
  • (K = 2): Groups ({1, 2, 4, 5, 6, 7}) and ({3, 8, 9, 10, 11, 12}).
  • (K = 3): Groups ({1, 2, 4, 6}), ({3, 5, 8, 12}) and ({7, 9, 10, 11}).

In the second case, either all students can be in a single group, or each should form a separate group.

In the third test case, the valid values of (K), with an example of each, are:

  • (K = 1): All students can be put into a single group.
  • (K = 2): Groups ({1, 2, 5, 7}) and ({3, 4, 6, 8}).
  • (K = 4): Groups ({1, 7}), ({2, 5}), ({3, 6}) and ({4, 8}).