polycarp develop new version old video game PacMan though enjoy play original game do not like aspect decide alter rule bitin Polycarps version play PacMan collect pellet scatter game world avoid dangerous ghost difference original Polycarp do not like fact escape ghost original version game world divide n safe zone m onedirectional pathway guarantee PacMan reach safe zone since safe zone safe ghost attack PacMan danger traverse pathway PacMan start game safe zone sAll pellet scatter safe zone initially ith safe zone contain a_i pellet PacMan safe zone freely collect pellet the pellet disappear collect pellet game world collect new pellet spawn safe zone quantity a_i new pellet spawn ith zone the pellet respawne number time game essentially infinitepolycarp determined structure game world number pellet safe zone now try find game difficult there q goal game ith goal collect c_i pellet begin game Polycarp denote difficulty ith goal minimum number time player traverse onedirectional pathway order collect c_i pellet traverse pathway put PacMan danger if pathway traverse multiple time PacMan collect pellet include answer number timeshelp polycarp calculate difficulty goal