An undirected graph has n vertices numbered from 1 to n and m edges.
Read the edge list and print the adjacency matrix of the graph.
Recall that the adjacency matrix A of an undirected graph has
A[i][j] = 1 if there is an edge between vertices i and j, and
A[i][j] = 0 otherwise. The main diagonal contains only zeros
(the graph has no self-loops).
Input:
The first line contains two natural numbers n and m, separated by a space.
The following m lines each contain two natural numbers x and y
representing an edge between vertices x and y.
- 1 <= n <= 50
- 0 <= m <= n*(n-1)/2
- 1 <= x, y <= n, x != y
- the graph contains no duplicate edges
Output:
The program prints the adjacency matrix, with values on the same row
separated by a single space, one matrix row per output line.
Example:
Input:
5 4
1 2
1 3
2 4
3 5
Output:
0 1 1 0 0
1 0 0 1 0
1 0 0 0 1
0 1 0 0 0
0 0 1 0 0