#This is a program for implementing the Russian Peasant Problem
keepGoing = True
while keepGoing == True:
    print '===================================================='
    print
    numbers = raw_input("Please input the 2 numbers separated by a space:")

    a,b = numbers.split()
    a,b = int(a), int(b)

    product = 0
    flag = 0
    if b < 0:
        b = -b
        flag = 1

    while b > 0:
        print 'A =',a,'and B =',b
        if b%2 == 1:
            product+=a
            print 'B was odd, we add A to make the product:',product
        a = a*2
        b = b/2

    if flag:
        product = -product
        
    if product == 0:
        print "Product is zero(neither negative nor positive)"
    elif product < 0:
        print "Product is negative"
    else:
        print "Product is positive"

    print "The product of the two numbers is:" , product

    choice = raw_input("Do you want to continue?(y/n)")
    if choice== 'n' or choice=='N':
        keepGoing = False
        print 'Thanks for Playing'
    elif choice == 'y' or choice == 'Y':
        keepGoing = True
    else:
        keepGoing = False
        print 'Bad input, quitting'
        
            
