eolymp
bolt
Try our new interface for solving problems
Problems

From adjacency matrix to adjacency list

From adjacency matrix to adjacency list

A simple directed graph is given with an adjacency matrix. Print its representation in the form of adjacency list. \InputFile First line contains the number of vertices in a graph $n~(1 \le n \le 100)$. Then the adjacency matrix is given. It is guaranteed that graph does not contain loops. \OutputFile Print $n$ lines --- the adjacency list of the graph. Print in the $i$-th line the number of edges adjacent to the $i$-th vertex, and then the vertex numbers where these edges go in increasing order. \includegraphics{https://static.e-olymp.com/content/4d/4df7609ab53a66562ff79b1398cba1d0974c5685.gif}
Time limit 1 second
Memory limit 128 MiB
Input example #1
5
0 0 1 0 0
1 0 1 0 0
0 0 0 0 1
1 1 0 0 0
1 1 0 0 0
Output example #1
1 3
2 1 3
1 5
2 1 2
2 1 2