Fegla's Scooter Test Ride

No attempts yetTime limit1sMemory limit256 MB

Problem

Fegla rides a small scooter to get around inside a building. On the day he was judging a contest his scooter broke down, and Hamzawy repaired it in the judging room. To check that the repair worked, Fegla wants to leave the judging room, ride a loop through the building, and come back to the room he started from. He cannot leave the judging team alone for long, so he wants the route that passes through the fewest rooms, and the route has to visit at least one room other than the starting one.

Fegla cannot open doors, he can only push them with the scooter, so a connection between two rooms can be taken in one fixed direction only.

You are given the number of rooms and the connections between them. Find the smallest number of distinct rooms on a route that starts at some room, visits at least one other room, and returns to the starting room. For example, a route that goes from room 11 to room 22, then to room 33, then back to room 11 passes through 33 rooms. The answer is therefore always at least 22.

Input

The first line contains one integer TT, the number of test cases (1T1001 \le T \le 100).

The first line of each test case contains two integers NN and MM separated by a space, the number of rooms and the number of connections (1N10001 \le N \le 1000, 0M1060 \le M \le 10^6).

Each of the next MM lines contains two different integers uu and vv separated by a space (1u,vN1 \le u, v \le N), meaning there is a connection that goes from room uu to room vv. A pair of rooms may have several connections and several routes between them.

Output

For each test case print one line in the form Case n: R, where nn is the test case number starting from 11 and RR is the number of distinct rooms on the shortest such route. If no such route exists, RR is 1-1.