def distribute(h,b):
    if h < 1:
        return "B"*b
    if b < 1:
        return "H"*h
    ans=""
    if h > b:
        q = h//b
        r = h-q*b
        hperb = "H"*q
        for x in distribute(r, b):
            if x == "B":
                ans += hperb
            ans+=x
    else:
        q = b//h
        r = b-q*h
        bperh = "B"*q
        for x in distribute(h, r):
            if x == "H":
                ans += bperh
            ans+=x
    return ans

print (distribute(1,10))
print (distribute(2,10))
print (distribute(3,10))
print (distribute(4,10))
print (distribute(5,10))
print (distribute(6,10))
print (distribute(7,10))
print (distribute(8,10))
print (distribute(9,10))
print (distribute(10,10))
