You are given a network of directed graph of \(N\) vertices and \(M\) edges, where every edges' capacity is \(1\). An ordered pair \((u, v), u\not=v\) is good, if the maxflow is exactly \(1\) upon setting \(u\) as the source vertex and \(v\) as the sink vertex of the flow network. Find out if all of the ordered pairs \((u, v), u \not= v\) are good or not.
Note
- For ordered pairs, if \(x \not=y,\) then \((x, y) \not= (y, x)\).
- Flow Network
Input format
- First line: An integer \(T\) - number of testcases.
- Each test case's-
- First line: Two integers \(N, M\).
- \(i\)-th of the next \(M\) lines: two integers \(u_i, v_i\)- a directed edge from \(u_i\) to \(v_i\).
Output format
Print \(T\) lines- \(i\)-th line contains answer for \(i\)-th testcase. For a testcase, the answer is "Yes" if every ordered pair is good, "No" otherwise.
Constraints
- \(1 \le T \le 600000\)
- \(1 \le N \le 200000\)
- \(0 \le M \le 500000\)
- \(\sum N \le 600000\)
- \(\sum M \le 1500000\)
First testcase:
Second testcase:
All ordered pairs' maxflow is 1.
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor