function to find the gcd of a path
int find_gcd ( vector < int > arr ) { if ( arr . size ( ) == 1 ) return arr [ 0 ] ; int g = arr [ 0 ] ; for ( int i = 1 ; i < arr . size ( ) ; i ++ ) { g = gcd ( g , arr [ i ] ) ; } return g ; }