Mr Seckington weights his ternᵃʳʸ Mr Seckington is a mobile grocer.  He drives his van door-to-door selling his produce all around the nearby villages.  Mr Seckington needs a method to weigh the produce he is selling so he knows how much to charge his customers.  Because space is at such a premium on his van, he uses an interesting sequence of weights on his scale that minimizes the amount weights he needs to measure any integer number of grams.



The weights (in grams) are all powers of 3, i.e 1, 3, 9, 27, 81...  He puts what he is weighing on the left side of the scale and he can put weights on either side of the scale to measure a desired weight with integer granularity.

For example if he wants to  weigh out 2 grams of peppercorns, he will put a 1g weight on the left side, a 3g weight on the right side, and then he can load the peppercorns onto the left side until the scale balances.

Similarly if he wants to weigh out 30g of chocolate chips, he'll put 3g + 27g weights on the right side and load chocolate chips onto the left side until the scale balances.

Given a positive integer weight as input, output two lists - one with the weights that must go on the left side of the scale and the other with the weights that must go on the right side.

It should be clear from the output which is the left-side list and which is the right-side list.  E.g. always ordering left, then right is fine.

The ordering within the lists doesn't matter.

You should be able to support inputs at least up to 88,573 (31+32+...+310).

Input -&gt; Output
    1 -&gt; {}, {1}
    2 -&gt; {1}, {3}
    3 -&gt; {}, {3}
    4 -&gt; {}, {1 ,3}
    5 -&gt; {1, 3}, {9}
    6 -&gt; {3}, {9}
    7 -&gt; {3}, {1, 9}
    8 -&gt; {1}, {9}
    9 -&gt; {}, {9}
   10 -&gt; {}, {1, 9}
   13 -&gt; {}, {1, 3, 9}
   14 -&gt; {1, 3, 9}, {27}
   20 -&gt; {1, 9}, {3, 27}
  100 -&gt; {9}, {1, 27, 81}


Harold Seckington really did have a mobile grocery in the village that I grew up in.  However, I made up the bit about him using a ternary system of weights.
MATL, 39 bytes
`x3:H-@Z^3@:q^*!tXsG=~}1MZ)Xzt0&gt;&amp;)_Xh&amp;D

The output lists are in reversed order. Each list is actually a column array of numbers (square brackets, semicolon as separator). In MATL, as in MATLAB and Octave, an array with a single number is the  same as a number, so in that case the corresponding list doesn't have enclosing brackets.
Try it online! Or verifiy all test cases.
How it works
This keeps testing sets of weights of increasing size: the set {1}, then {1, 3}, then {1, 3, 9}, ... This is done with a do...while loop.
For any such set, containing k different weights, all possible distributions of those weights are tested.
A distribution of weights is defined by a vector of k numbers, where each number may be -1, 0,  1, meaning that the corresponding weight is on the left side, unused, or on the right side. For each distribution, the sum is compared with the target weight. This is done in a vectorized manner, using 2D arrays.
If for a given set of weights there is a distribution of those weights that matches the target, the solution has been found.