This page is still under construction.

Parts of this page are still being built. What you see may change.

Boys and Girls

Time limit2sMemory limit256 MB

Summary
Arrange n children in a circle with B/G so that exactly x stand next to a boy and exactly y next to a girl, output the lexicographically smallest.
Level

Easy2 of 10

Topics
Implementation, Brute force, String
Solved
No attempts yet

Problem

nn children stand in a circle. The neighbours of a child are the children standing directly beside that child in the circle. A child stands next to a boy if at least one of its neighbours is a boy, and stands next to a girl if at least one of its neighbours is a girl. When nn is 2, the two children are each other's only neighbour.

Find an arrangement in which exactly xx children stand next to a boy and exactly yy children stand next to a girl.

Input

The single line contains three integers nn, xx and yy separated by spaces (2≤n≤1000002 \le n \le 100000, 0≤x,y≤n0 \le x, y \le n).

Output

If no arrangement satisfies both counts, print Impossible.

Otherwise print one string of length nn. Write B for a boy and G for a girl, listing the children in the order you meet them while walking around the circle in one direction. Any child may be the starting one, so every rotation of an arrangement also satisfies the counts. If several strings satisfy the counts, print the lexicographically smallest one. In that comparison B comes before G.

Examples12

  1. Example 1

    Input
    10 5 7
    
    Expected output
    BGBGBGBGGG
    
  2. Example 2

    Input
    10 3 8
    
    Expected output
    Impossible
    
  3. Example 3

    Input
    2 1 1
    
    Expected output
    BG
    
  4. Example 4

    Input
    2 2 0
    
    Expected output
    BB
    
  5. Example 5

    Input
    2 0 2
    
    Expected output
    GG
    
  6. Example 6

    Input
    3 2 3
    
    Expected output
    BGG
    
  7. Example 7

    Input
    7 7 0
    
    Expected output
    BBBBBBB
    
  8. Example 8

    Input
    6 0 6
    
    Expected output
    GGGGGG
    
  9. Example 9

    Input
    12 12 12
    
    Expected output
    BBGGBBGGBBGG
    
  10. Example 10

    Input
    16 12 12
    
    Expected output
    BBBBBBGGBBGGGGGG
    
  11. Example 11

    Input
    16 13 13
    
    Expected output
    BBBBBGGBBGGBGGGG
    
  12. Example 12

    Input
    9 6 9
    
    Expected output
    BBGGBGGGG