Donghyeok has N friends. They wanted to give him a sequence for his birthday, but the sequence has far too many terms, so each friend gave him one number x together with the rule for building the sequence from it. Today the friends want to ask what the K-th term of their sequence is. Donghyeok memorized none of it, so compute the answers for him.
The sequence Mi built from the number xi given by the i-th friend follows this rule. Let A={xi0,xi1,xi2,…} be the set of the powers of xi. List every non-empty finite subset of A as A0,A1,A2,…, and let aj be the sum of all elements of the subset Aj. The sequence Mi is the list of those values aj sorted in increasing order, and no value appears twice.
For example, with x=3 the set is A={1,3,9,27,…} and the subset sums in increasing order give M=1,3,4,9,10,12,13,….