suppose give sequence S k pair integer a_1 b_1 a_2 b_2 dots a_k b_kYou perform follow operation choose position increase a_i 1 that perform exist position j ne j a_i a_j the cost operation b_i choose position decrease a_i 1 that perform exist position j a_i a_j 1 the cost operation b_i each operation perform arbitrary number time possibly zerolet fs minimum possible x exist sequence operation total cost x a_i S pairwise distinct now task you give sequence p consist n pair integer a_1 b_1 a_2 b_2 dots a_n b_n all b_i pairwise distinct Let p_i sequence consist pair p your task calculate value fP_1 fp_2 dot fP_n