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
btd la cua t ok
tội nghiệp chú bò≡(▔﹏▔)≡
thật là cảm lạnh!
câu chuyện cảm lạnh về con bò.
Bài này sao tồn tại được vậy
idk
cho em xin ý tưởng với ạ
if (i==a[a[a[i]]]) thì là tình tay ba nên in ra <3
Vui lòng không spoil lời giải!
bai hay
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
haha
đề hay
Sauce: CF