Driver Code
public static void Main ( String [ ] args ) { int [ ] arr = { 2 , 1 , 3 , 2 , 1 , 2 , 1 } ; int K = 2 , M = 2 ; for ( int i = 0 ; i < adj . Length ; i ++ ) adj [ i ] = new List < int > ( ) ;