DISGRAPH - Disconnected country


Cities of the ancient country GRAPH connected by two-way (bidirectional) roads so that from any city you can get to any other city. The Sultan wants to destroy some roads and divide the country into two separate (disconnected) areas, so that from the city of one area it was impossible to get to the city of another area. You are the Minister of transportation and your task is to minimize the number of roads that need to be destroyed. You have a lot of time and the Sultan hopes :-) that you will solve this task.

Input

The first line of input will contain one integer number 8 ≤ N ≤ 1400, number of cities in GRAPH. Follow N lines. Each line represents cities (direct neighbors) connected to the city number i (cities numbering is zero based) by one road. There will be 7 input files.

Output

One integer number. The minimum number of roads that need to be destroyed.

Example

Input:
8
1 2
0 2 3 
0 1 3
1 2 4
3 5 6
4 6 7
4 5 7
5 6
Output:
1

Example explanation

Destroy only one road from the third city to the fourth city and Sultan will be happy.

DISGRAPH


hide comments
julkas: 2018-05-16 13:55:12

@devilwolverine My pleasure. Best regards.

Vipul Srivastava: 2018-05-16 10:30:28

@julkas Thanks a lot, your test case helped me get AC.

Also I found the problem to be quite interesting and I think it should be in classical section.

Last edit: 2018-05-16 13:01:59
julkas: 2018-05-14 12:48:43

@xilinx OK. I know this problem. But ... :-) . There is difference. Thank you for comment.

Edit: They are same in theory. Same algo can applied to both problems. But in practice ACed algo for one problem may be fail for other. I just want solutions and comments from other users. If problems are really same, I will move my problem to tutor section

Last edit: 2018-05-14 19:49:36
[Rampage] Blue.Mary: 2018-05-14 12:14:15

A same problem already exists at SPOJ: http://www.spoj.com/problems/ADABANKET/

Edit: I've used the same program of that problem (IO format modified) to get AC here.

Last edit: 2018-05-14 17:12:14

Added by:julkas
Date:2018-05-05
Time limit:1s-11s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All