Breadth First Traversal

easy
1. You are given a graph, and a src vertex.
2. You are required to do a breadth first traversal and print which vertex is reached via which path, 
     starting from the src.

Note -> for output, check the sample output and question video.

Input Format

Input has been managed for you

Output Format

Check the sample output

Constraints

None

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
7
8
0 1 10
1 2 10
2 3 10
0 3 10
3 4 10
4 5 10
5 6 10
4 6 10
2
Output
2@2
1@21
3@23
0@210
4@234
5@2345
6@2346
Previous
Is Graph Bipartite
Next
Spread Of Infection

Related Questions