eolymp
bolt
Try our new interface for solving problems
Problems

The incidence matrix

The incidence matrix

Vertex of the graph \textbf{u} is \textit{incident} to edge \textbf{e}, if \textbf{u} is one of the endpoints of edge \textbf{e}. Similarly, an edge \textbf{e} is \textit{incident }vertex \textbf{u}, if one end of the \textbf{e} - is the pinnacle of \textbf{u}. \textit{The incidence matrix} of a graph \textbf{G=(V, E)} is a rectangular table of |\textbf{V}| rows and |\textbf{E}| columns, where at the intersection of the \textbf{i}-th row and \textbf{j}-th column written one if vertex \textbf{i} is incident to edge \textbf{j}, and zero otherwise. Given an undirected graph. Bring it the incidence matrix. \InputFile The first line of the input file are given numbers \textbf{N} and \textbf{M} are separated by a space - the number of vertices and edges in the graph, respectively (\textbf{1} ≤ \textbf{N} ≤ \textbf{1000}, \textbf{0} ≤ \textbf{M} ≤ \textbf{10000}). The next \textbf{M} lines contain two numbers \textbf{u_i} and \textbf{v_i} in space (\textbf{1} ≤ \textbf{u_i}, \textbf{v_i} ≤ \textbf{N}); each such line means that there is an edge in the graph between the vertices \textbf{u_i} and \textbf{v_i}. The ribs are numbered in the order in which they are given in the input file, starting with one. \OutputFile Derive the output file \textbf{N} lines of \textbf{M} numbers each. \textbf{j}-th element of the \textbf{i}-th row must be equal to unity if vertex \textbf{i} is incident to edge \textbf{j} and zero otherwise. Separate adjacent row elements with a single space.
Time limit 1 second
Memory limit 64 MiB
Input example #1
3 2
1 2
2 3
Output example #1
1 0
1 1
0 1