#P440. 【例77.1】模拟链表

【例77.1】模拟链表

Description

In graph theory programming, adjacency lists are commonly used as data structures. Since dynamic pointers are slower than static arrays for access, many OI contestants use arrays to simulate pointers. Let's learn this programming method.
There are NN vertices, numbered from 11 to NN. There are MM edges, each represented by the two vertices it connects, such as (33, 88), indicating an edge between vertices 33 and 88 (undirected edge). Please output the vertices adjacent to each vertex through edges.

Input Format

The first line contains two integers NN and MM, where NN is in the range [11...50005000] and MM is in the range [11...100000100000]. The next MM lines each contain two integers representing an edge.

Output Format

NN lines, where the first number kk in the ii-th line indicates how many edges are connected to vertex ii, followed by kk numbers indicating which kk vertices are connected to vertex ii by an edge.

Sample

5 6
1 3
2 4
1 4
2 3
3 5
2 5
2 4 3
3 5 3 4
3 5 2 1
2 1 2
2 2 3