P3599 [CF1441F] Matching
NOI
题目描述

You are given a connected planar graph and the coordinates of all its vertices. Check if it has exactly one perfect matching.

Input

Each test contains multiple test cases. The first line contains an integer $t$ ($1 \le t \le 100\,000$), denoting the number of test cases, followed by a description of the test cases.

The first line of each test case contains two integers $n, m$ ($2 \le n \le 200\,000; n-1 \le m \le 3n$): the number of vertices and edges in the graph.

Each of the next $n$ lines contains pairs of integers $x_i, y_i$ ($-10^6 \le x_i, y_i \le 10^6$): coordinates of vertices. All vertices are guaranteed to be distinct. Next $m$ lines of each test case contains two integers $u_j, v_j$ ($1 \le u_j, v_j \le n$): graph edges.

The graph is guaranteed to be connected and has no loops or multi-edges.

The sum of all $n$ among all test cases is guaranteed to not exceed $200\,000$.

Output

For each test case, print $1$ if the graph has exactly one perfect matching, or $0$ if it does not.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 3 3 0 0 1 1 2 4 1 2 2 3 1 3 4 3 0 1 1 0 2 0 3 1 1 2 2 3 3 4 4 4 0 1 1 0 2 0 3 1 1 2 2 3 3 4 1 4 6 7 -2 1 -2 -1 -1 0 1 0 2 1 2 -1 1 2 1 3 2 3 3 4 4 5 4 6 5 6
样例输出
0 1 0 1
提示

An illustration for the first test case:

An illustration for the second test case:

An illustration for the third test case:

An illustration for the fourth test case: