Function to count distance
static void bfs ( int src ) { Vector < Integer > q = new Vector < Integer > ( ) ; q . add ( src ) ; vis [ src ] = 1 ; dis [ src ] = 0 ; while ( q . size ( ) != 0 ) { int curr = q . get ( 0 ) ; q . remove ( 0 ) ; for ( int x : lis . get ( curr ) ) {