Under construction

Still being built. Things may change

Divide and Conquer

Time limit8sMemory limit512 MB

Summary
Split the cities of a connected graph into three independent sets where two of them have equal size, and list all achievable equal sizes.
Level

Hard8 of 10

Topics
Graph, Divide and conquer, Dynamic programming, Greedy
Solved
No attempts yet

Problem

Taro, Hanako, and Jiro rule the kingdom of JAG as a group of three. The kingdom of JAG has NN cities, and some pairs of cities are connected by bidirectional roads. From any city, every other city is reachable by traversing one or more roads.

One day Taro and Hanako finally fell out, and the three decided to divide the cities among themselves and rule. But they became so hostile that Taro even hates the situation where a city he rules is directly connected by a single road to a city Hanako rules. So they decided to divide the cities to be ruled so that the following conditions hold.

  • Any pair consisting of a city ruled by Taro and a city ruled by Hanako is not directly connected by a road. This is because Taro and Hanako get along extremely badly.
  • Cities ruled by the same person are also not directly connected by a road. This is to encourage diplomacy by forcing them to route through cities under someone else's rule even in such a situation.
  • The total number of cities ruled by Taro and the total number of cities ruled by Hanako must be equal. This is because if the totals were not equal, Taro and Hanako would likely get along even worse. Here, Jiro is very broad-minded, so the total number of cities ruled by Jiro may be anything.

If the division satisfies the above conditions, the three can agree and rule, and they will not complain even if someone rules 0 cities. At this time, write a program that lists all possible values of the total number of cities ruled by Taro (= the total number of cities ruled by Hanako).

Input

The input consists of multiple datasets. The number of datasets is at most 50. Each dataset is given in the following format.

N M
u1 v1
...
uM vM

The first line contains two integers NN (2≤N≤1032 \le N \le 10^3) and MM (1≤M≤1031 \le M \le 10^3), representing the number of cities and the number of roads, respectively. Among the following MM lines, the ii-th line contains two integers uiu_i and viv_i (1≤ui<vi≤N1 \le u_i < v_i \le N), representing that the ii-th road connects city uiu_i and city viv_i bidirectionally. It is guaranteed that from any city, every other city is reachable by traversing one or more roads. Also, multiple roads connecting the same pair of cities are not given. That is, for all 1≤i<j≤M1 \le i < j \le M, (ui,vi)≠(uj,vj)(u_i, v_i) \ne (u_j, v_j) holds.

The end of the input is represented by a line consisting of two zeros.

Output

For each dataset, when there are KK possible values for the total number of cities ruled by Taro, first output KK on the first line, then output the possible totals one per line in ascending order.

Examples1

  1. Example 1

    Input
    6 7
    1 2
    1 4
    2 3
    2 5
    3 4
    4 5
    4 6
    2 1
    1 2
    3 3
    1 2
    1 3
    2 3
    4 3
    1 2
    2 3
    3 4
    5 4
    1 2
    2 3
    3 4
    4 5
    0 0
    
    Expected output
    2
    1
    2
    0
    0
    1
    1
    1
    1