Adjacency list to store edges
@ SuppressWarnings ( " unchecked " ) static Vector < Integer > [ ] adj = new Vector [ N ] ; static int [ ] lvl = new int [ N ] , dist1 = new int [ N ] , dist2 = new int [ N ] ;