Love Triangle

View as PDF

Submit solution


Points: 0.20 (partial)
Time limit: 1.0s
Memory limit: 256M
Input: stdin
Output: stdout

Problem type
Allowed languages
C, C++, Go, Java, Kotlin, Pascal, PyPy, Python, Rust, Scratch

MofK raises ~n~ cows, and he is very concerned about the romantic relationships between them. After observing for a while, MofK noticed that each cow is falling in love with exactly one other cow: cow ~i~ is having a crush on cow ~p_i~ (~p_i \neq i~).

As a true fan of the romcom genre, MofK cannot miss this opportunity. He wants to know if there are any ~3~ cows that form a love triangle. Three distinct cows ~a~, ~b~, and ~c~ form a love triangle if ~a~ loves ~b~, ~b~ loves ~c~, and ~c~ loves ~a~.

Please help MofK answer this question!

Input

Each input will consist of multiple test cases. The first line of the input contains a positive integer ~t~ (~1 \le t \le 100~) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a positive integer ~n~ (~3 \le n \le 100~) — the number of cows that MofK raises.

The next line of each test case contains ~n~ integers ~p_1, p_2, \dots, p_n~ (~1 \le p_i \le n~, ~p_i \neq i~) — the index of the cow that each cow is falling in love with.

Output

For each test case, print "<3" (without quotes) if there exists a love triangle among the cows, otherwise print "</3" (without quotes).

Scoring

If you solve this problem, you will receive ~500~ points.

Sample Input 1

2
5
4 1 5 2 2
4
2 3 4 1

Sample Output 1

<3
</3

Notes

In the first test case, we can find a love triangle among ~3~ cows ~[1, 2, 4]~ where ~1~ loves ~4~, ~4~ loves ~2~, and ~2~ loves ~1~.

In the second test case, although ~4~ cows form a love circle, there is no love triangle (this is a love quadrilateral!)


Comments

Please read the guidelines before commenting.



  • 0
    phuongisme  commented on Feb. 21, 2024, 3:40 a.m.

    cho em xin ý tưởng với ạ


  • 0
    phuchuynhchau123  commented on Feb. 2, 2024, 4:22 p.m.

    bai hay


  • -4
    nhatquang1310  commented on July 26, 2023, 7:53 a.m.

    nó ko xuống dòng Minhboss :)))


  • -10
    nhatquang1310  commented on July 26, 2023, 7:51 a.m.

    This comment is hidden due to too much negative feedback. Show it anyway.


  • 1
    KIET22  commented on June 24, 2023, 10:47 a.m.

    đề hay


  • 0
    Eren  commented on May 14, 2023, 12:17 a.m.

    Sauce: CF