Santa send present kid he large stack n present number 1 n topmost present number a_1 present a_2 present number a_n all number distinctsanta list m distinct present send b_1 b_2 b_m he send order appear listto send present Santa find stack remove present take present returning remove present stack so k present present Santa want send take 2k 1 second fortunately Santa speed process return present stack reorder wish present want present affect waywhat minimum time require send present provide Santa know list present send reorder present optimally Santa change order present interact stack present wayYour program answer t different test case