in certain video game player control hero characterize single integer value powerOn current level hero get system n cave number 1 n m tunnel each tunnel connect distinct cave any cave connect tunnel any cave reach cave move tunnelsthe hero start level cave 1 cave contain monsterthe hero cave tunnel if hero leave cave enter tunnel finish movement arrive opposite end tunnelthe hero use tunnel direction however hero use tunnel twice row Formally hero move cave cave j tunnel head cave immediately head cave connect cave j tunnelIt know tunnel come cave hero find dead end consider requirementTo pass level hero beat monster cave when hero enter cave time fight monster the hero beat monster cave heros power strictly great a_i in case beat monster hero power increase b_i if hero can not beat monster he s fight game end player losesafter hero beat monster cave subsequent visit cave will not consequence cave will not monsters heros power will not change eitherFind small possible power hero start level able beat monster pass level