adj is the adjacency matrix such that adj [ i ] [ j ] = 1 when there is an edge between i and j
vector < vector < int > > adj ; adj . resize ( n + 1 ) ; for ( int i = 0 ; i < adj . size ( ) ; i ++ ) adj [ i ] . resize ( n + 1 , 0 ) ;