Orz pandas are very lovely and we send them in QQ to show our respect to someone very diaoable, for example God Wan. Master Nuo loves to create new Orz panda emotion by combining some small Orz panda emotions. For example, by combining four Orz pandas A, Master Nuo can get a new emotion X. And by combining one Orz panda B and some Orz panda A's, he can get a new emotion Y.
A |
B |
X |
Y |
Master Nuo has N small Orz panda emotions, with period T1, T2, …, Tn. Now he wants to combine exactly K ones of them, in order to create one large Orz panda emotion. To keep the GIF file small, he wants to minimize T, the period of the large Orz panda emotion.
However, if the minimal T is larger than 1000, the emotion will be too large to be sent. So Master Nuo would simply type “Orz” in QQ, instead of sending an emotion.