Saxena Uncle had been planning the wedding reception of his beloved daughter. For the same reason, he went off to buy gold on an auspicious day. However the gold merchant has gold bars only in weights of 1,3,9,27,81...3k units and just one bar of each weight is available. Saxena Uncle wants to buy uncut bars. He wants to keep N units of gold for his daughter and give away the rest as gift to her in-laws. Also it is considered auspicious if the gift consists of uncut bars. Help him by finding the minimum amount of gold to be gifted for each value of N.
Note : If the amount of total gold exceeds 107 output 0.
Input
Input consists of only one integer N denoting the gold needed to buy for the wedding .
Output
Output two integers separated with a space – the minimum total gold Uncle has to buy and the amount of gold gifted to the in-laws.
Constraint
1 ≤ N ≤ 107.
For the given sample input, Saxena uncle buys 9 units of gold which is the minimum amount that satisfies all conditions.9 can be expressed as a power of 3 and he gifts 4 units to in-laws.4 can also be expressed in sums of powers of 3 i.e. 4=1+3