C # implementation of the approach
using System ; using System . Collections . Generic ; class GFG { static int cnt = 0 ; static List < int > [ ] graph = new List < int > [ 100 ] ; static String [ ] weight = new String [ 100 ] ;