#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 mm religions and kk gods. 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 integers n,m,kn,m,k.

Each of the next nn lines consists a number representing the religion ii that this person believes in.

Each of the last mm lines begins with a number ss, representing the count of deities associated with this religion. The following ss numbers jj denote the specific deities of this religion.

Output Format

One line consisting of the ID of the most popular deity. If there are ties in the number of believers, the one with the smaller number will be selected.

Samples

5 2 3
1
1
2
2
1
2 1 2
2 1 3
1
10 3 5
1
2
3
2
1
2
1
2
3
1
3 1 3 5
2 2 4
2 3 4
3

Data Range

$1 \le n \le 114514,1 \le i \le m \le 4444,1 \le s,j \le k \le 8888,1 \le \sum s \le 5088380.$