function to count distance
void bfs ( int src ) { queue < int > q ; q . push ( src ) ; vis [ src ] = 1 ; dis [ src ] = 0 ; while ( ! q . empty ( ) ) { int curr = q . front ( ) ; q . pop ( ) ; for ( int x : lis [ curr ] ) {