This page is still under construction.

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

AB String

Interview

Time limit2sMemory limit512 MB

Summary
Find the length-N A/B string whose number of (A before B) pairs equals K, choosing the lexicographically smallest such string.
Level

Medium4 of 10

Topics
Greedy, Combinatorics, String
Solved
No attempts yet

Problem

You are given two integers NN and KK. Find a string SS that satisfies both conditions below.

  • SS has length NN and uses only the letters 'A' and 'B'.
  • Exactly KK pairs (i,j)(i, j) satisfy 0≤i<j<N0 \le i < j < N, character ii of SS is 'A', and character jj of SS is 'B'. Positions are counted from 0.

If more than one string satisfies both conditions, find the lexicographically smallest one. In lexicographic order 'A' comes before 'B'.

Input

The first line contains NN and KK, separated by a space. (2≤N≤502 \le N \le 50, 0≤K≤N(N−1)/20 \le K \le N(N-1)/2)

Output

Print the lexicographically smallest string SS that satisfies the conditions. If no such SS exists, print -1.

Examples4

  1. Example 1

    Input
    3 2
    
    Expected output
    AAB
    
  2. Example 2

    Input
    2 0
    
    Expected output
    AA
    
  3. Example 3

    Input
    5 8
    
    Expected output
    -1
    
  4. Example 4

    Input
    10 12
    
    Expected output
    AAAAAABBAA