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.



  • -4
    khanhlani  commented on Aug. 21, 2024, 11:30 a.m.

    btd la cua t ok


  • 0
    doanhoang0102  commented on Aug. 19, 2024, 1:12 p.m.

    tội nghiệp chú bò≡(▔﹏▔)≡


    • 0
      PTKhoa  commented on Aug. 19, 2024, 1:13 p.m.

      thật là cảm lạnh!


  • 0
    PTKhoa  commented on Aug. 19, 2024, 1:11 p.m.

    câu chuyện cảm lạnh về con bò.


  • -2
    HieuTrong  commented on June 29, 2024, 4:58 a.m.

    Bài này sao tồn tại được vậy


    • -2
      PTKhoa  commented on Aug. 19, 2024, 1:09 p.m.

      idk


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

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


    • 6
      nccuongtq2023  commented on March 18, 2024, 10:01 a.m.

      if (i==a[a[a[i]]]) thì là tình tay ba nên in ra <3


      • 0
        nhanhtq2023  commented on March 18, 2024, 11:34 a.m.

        Vui lòng không spoil lời giải!


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

    bai hay


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

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


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

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


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

    đề hay


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

    Sauce: CF