Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Expandable ListView

Limits 1s, 512 MB

Minas is working on his new language. He want to add a feature call expandable listview. Here he explains how it works.

  1. It should have some parent node and there should have some child node under parent node.
  2. First only parent row are visible. If any parent row is clicked child row should be visible if its child are not visible otherwise child’s should be hidden. Each click in parent row toggled the visibility of child row. No effect on child row click.
    Main problem in his implementation is row id’s change when a parent row is clicked.

You can see that after clicking on parent_1, id of parent_2 and paretn_3 is changed.

Now Minas will give you the number of parent node and their corresponding number of child node. There will be some query each query Minas will give you id of the clicked node. You need to tell it is parent node or child node and do the clicked operation.

Input

Input starts with an integer T (T <= 30) denoting the number of test cases.
Each case starts with a line containing an integer n (n <= 100000) denoting number of parent node. Each of the next lines containing n integers ai (1 <= ai <= 10000, 1 <= i <= n) denoting number of child node for ith parent. Next Line contain an integer q (1 <= q <= 10000) donating number of queries. Next q line contain one integer x (1 <= x <= number of visible row) donating id of clicked node.

Output

For each case, print the case number and for each query print “Parent” if clicked node is parent otherwise print “Child”.

Sample

InputOutput
1
3
2 2 2
5
1
2
4
1
2
Case 1:
Parent
Child
Parent
Parent
Parent

Discussion

Statistics


90% Solution Ratio

AashiqEarliest, Jan '17

Uniquepro.Fastest, 0.3s

sinamhdvLightest, 2.6 MB

seyedsszShortest, 1508B

Submit

Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.