#K63002. Landsville Connectivity Problem

    ID: 31656 Type: Default 1000ms 256MiB

Landsville Connectivity Problem

Landsville Connectivity Problem

In Landsville, a group of parks is connected by various bidirectional pathways. Your task is to determine whether all the parks in each test case are fully connected. If they are connected, print YES X, where X is the minimal number of pathways required to keep them connected. The minimal number is computed by the formula \(P-1\), where \(P\) is the number of parks. Otherwise, print NO.

Note: All pathways are bidirectional and there can be extra pathways provided. However, the minimal requirement for connectivity is ensured if \(P-1\) pathways exist that connect all the parks.

inputFormat

The first line of the input contains an integer T representing the number of test cases. For each test case:

  • The first line contains two integers P and C, where P is the number of parks and C is the number of pathways.
  • Each of the next C lines contains two integers u and v indicating there is a bidirectional pathway connecting park u and park v.

outputFormat

For each test case, output a single line:

  • If all parks are fully connected, print YES X where X = P-1.
  • If they are not connected, print NO.

The output for each test case should be printed on a new line.

## sample
2
5 4
1 2
2 3
3 4
4 5
4 2
1 2
3 4
YES 4

NO

</p>