favorite We need a little bit of your help to keep things running, click on this banner to learn more

Graph representation

From adjacency list to adjacency matrix

Simple directed graph is given by adjacency list. Print its representation in the form of adjacency matrix.


The first line contains the number of vertices n (1n100). Then n lines are given. The i-th line contains the description of all edges, outgoing from the i-th vertex. Description starts with the number of outgoing edges. Then given the vertex numbers where the edges go. All vertices are numbered from 1 to n.


Print the adjacency matrix of oriented graph.

Time limit 1 second
Memory limit 128 MiB
Input example #1
2 2 3
1 2
Output example #1
0 1 1
0 0 0
0 1 0