K. K-Places
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

After qualifying for the ICPC Worlds, the $$$N$$$ MaratonaCIn members decided to celebrate with a trip together. They found $$$K$$$ tourist hotspots, conveniently numbered from $$$1$$$ to $$$K$$$. There is, however, a problem: maratonistas (the members of MaratonaCIn) are notoriously picky. The $$$i$$$-th member has $$$m_i$$$ places they will refuse to go.

Wanting to make everyone happy, they are willing to split into groups as long as each group is a contiguous interval of the original list. In order to help Coach Palão plan the trip, answer $$$Q$$$ queries: what places can be visited if he brings the members in a given interval $$$[l, r]$$$?

Input

The first line contains two integers $$$N$$$ ($$$1 \le N \le 10^5$$$) and $$$K$$$ ($$$1 \le K \le 60$$$).

Then, $$$N$$$ lines follow. The $$$i$$$-th line starts with an integer $$$m_i$$$ ($$$0 \le m_i \le K$$$), the amount of places the $$$i$$$-th person refuses to go. After that, $$$m_i$$$ integers $$$p_j$$$ ($$$1 \le p_j \le K$$$), the numbers of the places.

Then one integer $$$Q$$$ ($$$1 \le Q \le 2 \cdot 10^5$$$), the number of queries.

Finally, $$$Q$$$ lines containing two integers $$$l$$$ $$$r$$$, ($$$1 \le l \le r \le N$$$).

Output

For every query, output the places the group consisting of every maratonista from $$$l$$$ to $$$r$$$ can go, in ascending order. If there isn't anywhere they can go, output $$$-1$$$ instead.

Example
Input
5 6
1 1
3 2 4 6
2 2 5
0
2 1 3
4
1 3
3 5
3 4
1 5
Output
3 
4 6 
1 3 4 6 
-1
Note

Note that the output must be in strictly ascending order or your answer might not be accepted.