## A

One day, Artem's channel was blocked on one of the video hosting sites. "Well, they blocked it and blocked it," he thought and decided to re-upload his videos to other video hosting sites. Artem decided to approach this process from a research point of view in order to find out which video hosting site is better.

To begin with, Artem decided that he would upload each video to exactly one video hosting site so that his viewers would have the motivation to subscribe to all video hosting sites. After all, if significantly more or fewer viewers subscribe to some video hosting site, this could distort the viewing statistics.

Then Artem decided that the minimum and maximum number of videos he uploaded to each video hosting site should differ as little as possible. After all, if significantly more or fewer videos are uploaded to some video hosting site, this could also distort the viewing statistics.

Artem was about to upload the videos to the video hosting sites, but he noticed that each video could be attributed to exactly one topic. Different topics may be interesting to different viewers. Therefore, Artem decided that for even greater uniformity, it is necessary to upload videos so that for each topic the minimum and maximum number of uploaded videos of this topic on each video hosting site also differed as little as possible.

Artem realized that he had overcomplicated his task and now he cannot cope without your help.

Input data format
The first line contains three natural numbers
N, M, K (1≤N≤10^5, 1≤M,K≤N) — the number of videos, topics and video hosting sites. All of them are numbered from one.
The second line contains N natural numbers t_i (1≤t_i≤M) — the topic of the i-th video.

Output data format
Print K lines. Each line x should begin with an integer S — the number of videos uploaded to the video hosting site with number x. Then come S integers — the numbers of the corresponding videos.

Example 1

Input:

```
10 4 3
1 2 2 3 3 3 4 4 4 4
```

Output:

```
4 1 4 7 10
3 2 5 8
3 3 6 9
```

Solution:

```python
from collections import defaultdict

N, M, K = map(int, input().split())
t_list = list(map(int, input().split()))

topics = defaultdict(list)
for idx, t in enumerate(t_list, start=1):
    topics[t].append(idx)

hosts = [[] for _ in range(K)]
next_host = 0

for t in range(1, M+1):
    videos = topics[t]
    n_t = len(videos)
    base = n_t // K
    rem = n_t % K
    ptr_v = 0

    if base > 0:
        for host in range(K):
            assign = videos[ptr_v:ptr_v+base]
            hosts[host].extend(assign)
            ptr_v += base

    for i in range(rem):
        host = (next_host + i) % K
        hosts[host].append(videos[ptr_v])
        ptr_v += 1

    next_host = (next_host + rem) % K

for host in hosts:
    output = [str(len(host))] + [str(v) for v in host]
    print(' '.join(output))
```

## B

That same Artem from one of the previous tasks told Yura about an unusual way of dividing videos and topics by video hosting sites. Yura couldn't quite understand the general rule of partitioning and decided to ask Artem several questions with specific examples of video partitions. For each example, Artem must answer whether it is correct or not. In this way, Yura hopes to understand the general rule from specific examples.

Tired of the monotony of questions, Artem decided to automate his answers.

The maximum points for the task is 100.

Input data format

The first line contains one natural number
Q (1≤Q≤10) is the number of questions that Yura will ask. Then follow Q questions.
Each question begins with a line that contains three natural numbers N, M, K (1≤N≤10^5, 1≤M,K≤N) — the number of videos, topics, and video hosting sites. They are all numbered from one.
The second line of the question contains N natural numbers t_i (1≤t_i≤M) — the topic of the i-th video.
Then follow K lines that describe the partition. Each line starts with a non-negative integer S — the number of videos uploaded to the corresponding video hosting. Then in the same line follow S natural numbers not exceeding N — the numbers of the corresponding videos.
It is guaranteed that the sum of S for all questions and video hostings and the sum of K for all questions do not exceed 10^5.

Output data format

Print Q lines, each of which should contain "YES" if the corresponding partition is correct, and "NO" otherwise.

Example 1

Input

```
2
10 4 3
1 2 2 3 3 3 4 4 4 4
4 1 2 4 8
3 7 3 5
3 9 6 10
10 4 3
1 2 2 3 3 3 4 4 4 4
4 1 2 3 4
3 5 6 7
3 8 9 10
```

Output

```
YES
NO
```

Solve problem B.