~/algor $ cat contests/round-5/A
A. Adjacency lists
An undirected graph with vertices and edges is given. The vertices are numbered from to . For every vertex print its neighbours — the vertices joined to it by an edge — in increasing order.
Input
The first line contains two integers: and . Each of the next lines contains two positive integers: and — the vertices joined by an edge.
Output
lines: the -th line contains first the number of neighbours of vertex , then the neighbours in increasing order.
Note
,
There is at most one edge between any pair of vertices.
Examples
5 5 1 2 1 3 4 1 2 3 3 5
3 2 3 4 2 1 3 3 1 2 5 1 1 1 3
3 0
0 0 0