Given number of edges '**E**' and vertices '**V**' of a bidirectional graph. Your task is to build a graph through adjacency list and print the adjacency list for each vertex.

**Input:**

The first line of input is T denoting the number of testcases.Then first line of each of the T contains two positive integer V and E where 'V' is the number of vertex and 'E' is number of edges in graph. Next, 'E' line contains two positive numbers showing that there is an edge between these two vertex.

**Output:**

For each vertex, print their connected nodes in order you are pushing them inside the list . See the given example.

**Constraints:**

1 <= T <= 200

1 <= V <= 10^{3}

1 <= E = V*(V-1)

**Example:**

**Input:**

2

5 7

0 1

0 4

1 2

1 3

1 4

2 3

3 4

3 3

0 1

1 2

2 0

**Output:**

0-> 1-> 4

1-> 0-> 2-> 3-> 4

2-> 1-> 3

3-> 1-> 2-> 4

4-> 0-> 1-> 3

0-> 1-> 2

1-> 0-> 2

2-> 1-> 0

**Explanation:
Testcase 1:** Given graph has 5 nodes and 7 edges. After creating adjacency list of given graph, we have list as:

0-> 1-> 4

1-> 0-> 2-> 3-> 4

2-> 1-> 3

3-> 1-> 2-> 4

4-> 0-> 1-> 3

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

preparecodinginterview_dot_com | 190 |

__murugan__ | 173 |

manvimahajan20 | 140 |

xiaoyan_yunche | 139 |

ShameekAgarwal | 116 |

preparecodinginterview_dot_com | 190 |

__murugan__ | 173 |

manvimahajan20 | 166 |

SoumyaKaushik | 146 |

arpit_anshuman | 140 |

blackshadows | 5331 |

Ibrahim Nash | 5219 |

akhayrutdinov | 5111 |

mb1973 | 4929 |

Quandray | 4567 |

Login to report an issue on this page.