Universal Cup Judging System

Universal Cup

Limite de temps : 3.0 s Limite de mémoire : 1024 MB Points totaux : 100 Hackable ✓
Statistiques

Description

Mr. Nežmah has a peculiar taste in triples. He likes $m$ unordered triples of pairwise distinct numbers $(a_i, b_i, c_i)$.

A cycle of length $k$ is a sequence of (not necessarily distinct) numbers $v_1, \dots, v_k$ where every three consecutive numbers form a triple Nežmah likes, as well as $(v_{k-1}, v_k, v_1)$ and $(v_k, v_1, v_2)$.

A cycle is crooked if its length is not divisible by $3$. Check whether there exists a crooked cycle.

Input

The first line contains an integer $t$ ($1 \le t \le 2 \cdot 10^4$), the number of test cases.

The first line of each test case contains an integer $m$ ($1 \le m \le 2 \cdot 10^5$), the number of triples.

The following $m$ lines contain the integers $a_i, b_i$, and $c_i$ ($1 \le a_i, b_i, c_i \le 2 \cdot 10^5$). It is guaranteed that $a_i, b_i$, and $c_i$ are pairwise distinct for each $i$, and that all unordered triples are distinct.

It is guaranteed that the sum of $m$ over all test cases does not exceed $2 \cdot 10^5$.

Output

For each test case, output yes if there exists a crooked cycle; otherwise, output no.

Samples

Sample 1

3
4
1 2 3
2 3 4
3 4 1
4 1 2
8
3 2 5
6 3 7
7 3 2
1 5 6
5 2 6
7 4 6
3 2 6
3 2 1
7
7 4 6
2 3 7
7 2 4
5 4 6
3 6 7
5 3 6
1 4 6
yes
yes
no

Note

In the second test case $(2, 3, 5, 2, 6, 3, 2, 7, 3, 6)$ forms a crooked cycle (although there are smaller ones as well).

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.