Friendly Brothers

Time limit2sMemory limit128 MB

Summary
Given a reduced fraction a/b, find the shortest repeating turn pattern (length at most 60) of two people eating half the remaining cake so one person's total share equals a/b.
Level

Medium6 of 10

Topics
Number theory, Math, Bit manipulation, Brute force
Solved
No attempts yet

Problem

Youngsik and Minsik are sharing a cake. Whenever someone takes a turn, that person eats exactly half of the cake that remains.

If they alternate in the order Youngsik, Minsik, Youngsik eats the following amounts.

YoungsikMinsik
1/21/4
1/81/16
1/321/64
1/1281/256
......

In this case, Youngsik eats 2/3 of the whole cake, and Minsik eats 1/3.

Now the two brothers will repeat a fixed pattern forever. Each character of the pattern represents one turn; after the last character, the pattern starts again from the beginning. Youngsik is written as *, and Minsik is written as -.

For the repeated pattern Youngsik, Minsik, Youngsik, the amounts are taken as follows.

YoungsikMinsikYoungsik
1/21/41/8
1/161/321/64
1/1281/2561/512
.........

With this pattern, Youngsik eats 5/7 of the whole cake.

You are given the target amount of cake Youngsik must eat as a reduced fraction a/b. Find the shortest repeating pattern that makes Youngsik eat exactly that amount.

Input

The first line contains two integers a and b. They are the numerator and denominator of the reduced fraction a/b.

Output

Print the eating pattern on the first line. In the pattern, print Youngsik's turns as * and Minsik's turns as -.

If no pattern of length at most 60 exists, print -1. If multiple patterns are possible, print the shortest one.

Constraints

  • 0 <= a <= b <= 2^63 - 1
  • a and b are relatively prime.

Examples6

  1. Example 1

    Input
    2 3
    
    Expected output
    *-
    
  2. Example 2

    Input
    5 7
    
    Expected output
    *-*
    
  3. Example 3

    Input
    0 1
    
    Expected output
    -
    
  4. Example 4

    Input
    5 9
    
    Expected output
    *---**
    
  5. Example 5

    Input
    1 2
    
    Expected output
    -1
    
  6. Example 6

    Input
    76861433640456464 76861433640456465
    
    Expected output
    ********************************************************----