codeforces#P1468M. Similar Sets
Similar Sets
Description
You are given sets of integers. The -th set contains integers.
Two sets are called similar if they share at least two common elements, i. e. there exist two integers and such that , and they both belong to each of the two sets.
Your task is to find two similar sets among the given ones, or report that there is no such pair of sets.
The first line contains a single integer () — the number of test cases. Then test cases follow.
The first line of each test case contains a single integer () the number of given sets. The following lines describe the sets. The -th line starts with an integer () — the number of integers in the -th set. Then integers , , ..., () follow — the elements of the -th set. It is guaranteed that all elements in each set are different.
The total number of elements in all sets in all test cases is not greater than .
For each test case, print the answer on a single line.
If there is no pair of similar sets, print -1.
Otherwise, print two different integers — the indices of the similar sets. The sets are numbered from to in the order they are given in the input. If there are multiple answers, print any of them.
Input
The first line contains a single integer () — the number of test cases. Then test cases follow.
The first line of each test case contains a single integer () the number of given sets. The following lines describe the sets. The -th line starts with an integer () — the number of integers in the -th set. Then integers , , ..., () follow — the elements of the -th set. It is guaranteed that all elements in each set are different.
The total number of elements in all sets in all test cases is not greater than .
Output
For each test case, print the answer on a single line.
If there is no pair of similar sets, print -1.
Otherwise, print two different integers — the indices of the similar sets. The sets are numbered from to in the order they are given in the input. If there are multiple answers, print any of them.