Atto Round 1 (Codeforces Round 1041, Div. 1 + Div. 2)
H
23 Rises Again
Codeforces
3100
原题
← G2→
翻译中…

Kiarash is picking strawberries to take home...

翻译中…

A graph is called candy if and only if the degree of every vertex in it is at most $2$.

翻译中…

You are given a simple, undirected, and connected graph $G$ of $n\le 30$ vertices, with a special property: each vertex belongs to at most $5$ simple cycles$^{\text{∗}}$.

翻译中…

What is the maximum number of edges among all subgraphs$^{\text{†}}$ of $G$ that are candy?

翻译中…

$^{\text{∗}}$A simple cycle is a connected subgraph such that each vertex has a degree of exactly $2$$^{\text{†}}$A subgraph of $G$ is a graph whose vertices and edges are subsets of $G$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 50$). The description of the test cases follows.

翻译中…

The first line of each test case contains two integers $n$ and $m$ ($3 \leq n \leq 30$, $n-1 \leq m \leq \frac{n(n-1)}{2}$) — the number of vertices and the number of edges.

翻译中…

Then $m$ lines follow, the $i$-th line containing two integers $u$ and $v$ ($1 \leq u, v \leq n$) — the two vertices that the $i$-th edge connects.

翻译中…

It is guaranteed that the given graph is simple and connected, and each vertex belongs to at most $5$ simple cycles.

翻译中…

It is guaranteed that the sum of $n^2$ over all test cases does not exceed $900$.

翻译中…

Output

翻译中…

For each test case, output a single integer — the maximum number of edges among all subgraphs that are candy graphs.

翻译中…

Note

翻译中…

In the first test case, you can select the edges marked in the image below. On the other hand, you can't select all the edges because the degree of vertex $3$ would exceed $2$. So the maximum number of edges among all subgraphs that are candy is $3$.

翻译中…

image

翻译中…

In the second test case, you can select the edges marked in the image below. It can be proven that any subgraph that is candy has at most $7$ edges.

翻译中…

image

翻译中…

In the third test case, the image below shows one of the subgraphs with the maximum possible number of edges that is candy.

翻译中…

image

翻译中…

样例

Input #1
3
4 4
1 2
1 3
2 3
3 4
7 10
1 2
1 3
1 4
2 4
3 4
4 5
4 6
5 6
5 7
6 7
9 10
1 2
1 3
3 4
3 7
4 5
4 6
5 6
7 8
7 9
8 9
Output #1
3
7
8
InputCopy OutputCopy
题目信息
题号
2127H
时间限制
5 s
内存限制
1024 MB
标签
暴力
DFS 及类似
动态规划
网络流
图匹配
图论
贪心
模拟
概率论
树

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。