QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100

#13175. Subdivision of Kingdom

統計

Byteasar, king of Byteotia, has finally decided to retire. He has two sons, however, and is unable to decide which one one of them should succeed him. Therefore he plans to split the kingdom into two halves, making each son a ruler.

After the division, watchtowers have to be built along the roads connecting the halves. Obviously, building them will be costly, so ideally there should be as little roads between the halves as possible.

Luckily, Byteotia consists of an even number of towns, connected by roads. Resulting from the division, each half-kingdom should contain half the towns. Each road connects (directly) two towns. The roads do not meet nor cross outside towns, though they can lead through flyovers or tunnels. Every two towns are directly connected by at most one road.

Which exact towns should lie in which half of the kingdom is a matter of great importance. You may assume that the land outside the towns can be partitioned in such a way that the roads connecting towns lying in the same half will not cross the border. On the other hand, one watchtower has to be built by each road connecting towns from different halves.

Write a programme that:

  • reads the descriptions of towns and the roads connecting them from the standard input,
  • determines such a partition of kingdom into halves that both the halves contain an equal number of towns and the number of roads connecting towns lying in different halves is minimum,
  • writes out the result to the standard output.

If more than one optimum partition exists, your programme should pick one of them arbitrarily.

Input

The first line of the standard input contains two integers n and m, separated by a single space, denoting the number of towns and number of roads respectively, $2 ≤ n ≤ 26$, $2 \mid n$, $0 ≤ m ≤ \frac{n\cdot(n-1)}{2}$. The towns are numbered from $1$ to $n$. Each of the following $m$ lines contains two integers separated by a single space. The line no. $(i+1)$ (for $i=1,2,…,m$) contains the numbers $u_i$ and $v_i$, $1 ≤ u_i < v_i ≤ n$. These denote a road connecting $u_i$ and $v_i$.

Output

Your programme should write out exactly one line to the standard output. It should contain $\frac{n}{2}$ integers separated by single spaces. These should be the numbers of towns belonging to the same half of the kingdom the town no. 1 does, in an increasing order.

Example

Input

6 8
1 2
1 6
2 3
2 5
2 6
3 4
4 5
5 6

Output

1 2 6
problem_13175_1.jpg

The dashed line in the figure shows the optimum partition, which requires building as little as watchtowers.

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.