I am not sure wether you understand correctly the problem or not. In this problem, the graph is not given by an adjacency list or an adjacency matrix as you are describing. We are dealing here with a graph of objects. Each object contains a list of its neighbors. So if a node `node1`

has `node2`

in its neighbors list, then `node2`

will also have `node1`

in its own neighbors list since the graph is undirected.

You do not need to understand what `{0,1,2#1,2#2,2}`

to solve the problem. Your code will never deal with inputs that look like that. (You have to understand it however to debug your code as the online judge will show you the inputs of the tests serialized this way.)

`{0,1,2#1,2#2,2}`

is the serialization of an undirected graph, it is not the concatenation of the adjacency lists. It is implied that this represents an undirected graph. `0,1,2`

means that there is an edge between 0 and 1, and an edge between 0 and 2. There is no need later in serialization to encode again the edge between 1 and 0 since it has already been encoded.