eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Cycles of Lanes

Cycles of Lanes

\includegraphics{https://static.e-olymp.com/content/7f/7f13dff68443b1a82f025ce2542b97eedd09b317.jpg} Each of the \textbf{M} lanes of the Park of Polytechnic University of Bucharest connects two of the \textbf{N} crossroads of the park (labeled from \textbf{1} to \textbf{N}). There is no pair of crossroads connected by more than one lane and it is possible to pass from each crossroad to each other crossroad by a path composed of one or more lanes. A cycle of lanes is simple when passes through each of its crossroads exactly once. The administration of the University would like to put on the lanes pictures of the winners of Regional Collegiate Programming Contest in such way that the pictures of winners from the same university to be on the lanes of a same simple cycle. That is why the administration would like to assign the longest simple cycles of lanes to most successful universities. The problem is to find the longest cycles? Fortunately, it happens that each lane of the park is participating in no more than one simple cycle (see the Figure). On the first line of the input file the number \textbf{T} of the test cases will be given. Each test case starts with a line with the positive integers \textbf{N} and \textbf{M}, separated by interval (\textbf{4} <= \textbf{N} <= \textbf{4444}). Each of the next M lines of the test case contains the labels of one of the pairs of crossroads connected by a lane. For each of the test cases, on a single line of the output, print the length of a maximal simple cycle.
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
1
7 8
3 4
1 4
1 3
7 1
2 7
7 5
5 6
6 2
Выходные данные #1
4
Источник Southeastern European Regional Programming Contest, Bucharest, Romania, October 17, 2009