AT_agc071_c [AGC071C] Orientable as Desired
Description
There is a simple connected undirected graph $ G $ with $ N $ vertices and $ M $ edges, where the vertices are labeled $ 1,2,\dots,N $ . The $ i $ -th edge connects two vertices $ u_i $ and $ v_i $ .
Determine whether there exists a length- $ N $ sequence of non-negative integers $ X=(X_1,X_2,\dots,X_N) $ that satisfies all of the following conditions:
- $ X_v $ does not exceed the degree of vertex $ v $ in $ G $ for each $ v=1,2,\dots,N $ .
- There is **no** directed graph obtained by assigning directions to the $ M $ edges of $ G $ in which, for each $ v=1,2,\dots,N $ , either the in-degree or the out-degree of $ v $ equals $ X_v $ .
You have $ T $ test cases; solve each of them.
Input Format
The input is given from Standard Input in the following format:
> $ T $ $ \mathrm{case}_1 $ $ \vdots $ $ \mathrm{case}_T $
Each case is given in the following format:
> $ N $ $ M $ $ u_1 $ $ v_1 $ $ u_2 $ $ v_2 $ $ \vdots $ $ u_M $ $ v_M $
Output Format
Print $ T $ lines. The $ i $ -th line should contain the answer for the $ i $ -th test case. If there exists an $ X $ that satisfies the conditions, print `Yes`; otherwise, print `No`.
Explanation/Hint
### Sample Explanation 1
In the first test case, for example, $ X=(2,2,2,1) $ satisfies the conditions.
In the second test case, no sequence $ X $ satisfies the conditions.
### Constraints
- $ 1 \leq T \leq 10^5 $
- $ 2 \leq N \leq 2 \times 10^5 $
- $ N-1 \leq M \leq 2 \times 10^5 $
- $ 1 \leq u_i, v_i \leq N $
- All input values are integers.
- The graph $ G $ given in the input is a simple connected undirected graph.
- The sum of $ N $ over all test cases in each input is at most $ 2 \times 10^5 $ .
- The sum of $ M $ over all test cases in each input is at most $ 2 \times 10^5 $ .