#P37. [KBC002E] Gods
[KBC002E] Gods
Source
This problem is adapted from Long Long OJ. All rights reserved.
Problem Description
In this magical world, there are religions (with ID's of respectively) and gods (with ID's of respectively). Each person can only believe in one religion, but a single religion may have many followers. A god can appear in multiple religions, and a single religion may also have many gods. Once someone believes in a religion, they will also believe in all the gods associated with that religion. Xiao Ming is a theologian who wants to know which god is the most popular, but he isn't very good at math, so please help him.
Input Format
The first line consists of three positive integers .
Each of the next lines consists a positive integer representing the religion ID that this person believes in.
Each of the last lines begins with a positive integer , representing the count of gods associated with this religion. The following positive integers (given in strictly increasing order) denote the specific gods of this religion.
It is guaranteed that the sum of over the whole test case does not exceed .
Output Format
One line consisting of integers, the -th of which represents the number of persons believing in the god with an ID of .
Samples
5 2 3
1
1
2
2
1
2 1 2
2 1 3
5 3 2
10 3 5
1
2
3
2
1
2
1
2
3
1
3 1 3 5
2 2 4
2 3 4
4 4 6 6 4