in Berland city S tram engine house tram three people work house tram driver conductor head engine house the tram leave engine house morning drive loop route the tram need exactly c minute complete route the head engine house control trams movement go outside c minute tram drive engine house head leave driver bonus second lateIt Afterwards Berland Federal Budget give money tramline S happen mean plan the tramline rebuild result turn huge network the previous loop route destroy S n crossroad m tramline link pair crossroad the traffic Berland way tram tramline direction there tramline crossroad way opposite way every tramline link different crossroad crossroad outgoing tramlineSo tramline build reason gave think increase number tram S the tram continue ride driver excellent opportunity rid unending control engine house head for tramline network choose route freely now crossroad driver arbitrarily choose way the tram part S return way traffic the driver afraid challenge night city asleep return engine house safely drive tramline opposite directionthe city people rejoice wait tram appear street year however driver behavior enrage engine house head now tries carry insidious plan instal camera look rebellious tramthe plan go follow the head engine house want install camera crossroad choose period time t t minute turn away favourite tv check tram also head engine house want moment time divisible t moment tram appear crossroad camera There camera crossroad engine house prevent possible terrorist attack engine house head among possible plan engine house head choose plan large possible value t hate distract favourite tv if plan unique pick plan require minimal possible number camera find plan