in world Compfestnesia Pak Chanek discover secret underground dungeon inside treasure chest surround n statue arrange circular manner the statue number 0 n1 statue leave statue i1 statue n1 leave statue 0pak Chanek observe statue hold crystal ball integer 0 m1 inclusive Lets integer crystal ball statue a_ithe dungeon provide instruction integer crystal ball 0 order open treasure chest to achieve Pak Chanek give integer k zero operation in single operation Pak Chanek following choose exactly k consecutive statue in word choose statue p p1 bmod n p2 bmod n p3 bmod n ldot pk1 bmod n choose index p Do follow for choose statue change value a_i a_i1 bmod m for choose statue change value a_i a_i1 bmod m help Pak Chanek find minimum possible number operation open treasure chest