You are given a set S consisting of non-negative powers of three S={1, 3, 9, 27, ...}. Consider the sequence of all non-empty subsets of S ordered by the value of the sum of their elements. You are also given a single element n. You are required to find the subset at the nth position in the sequence and print it in increasing order of its elements.
Input format
Output format
Constraints
1≤t≤1051≤n≤1012
In the first test case, of the example n = 1 and if we write all the subsets in increasing order of the sum of their elements the set {1} comes at the 1st position.
In the second test case, the set {3,9} comes at the 6th position.
In the third test case, the set {1,3,27} comes at the 11th position.