Alice receive set Toy Train Bob it consist train connected railway network n station enumerate 1 n the train occupy station time travel network station circular manner more precisely immediate station train visit station station i1 1 leq n station 1 n it take train 1 second travel station describedBob give Alice fun task leave deliver m candy initially station independent destination train the candy enumerate 1 m Candy 1 leq leq m station a_i deliver station b_i a_i neq b_i the blue number candy correspond b_i value the image correspond 1st example the train infinite capacity possible load number candy station however candy load station train leave station you choose candy station the time take candy negligiblenow Alice wonder time need train deliver candy your task find station minimum time train need deliver candy start