You have a description of a lever as string s. We'll represent the string length as record |s|, then the lever looks as a horizontal bar with weights of length |s| - 1 with exactly one pivot. We will assume that the bar is a segment on the Ox axis between points 0 and |s| - 1.

The decoding of the lever description is given below.

  If the i-th character of the string equals "^", that means that at coordinate i there is the pivot under the bar.  If the i-th character of the string equals "=", that means that at coordinate i there is nothing lying on the bar.  If the i-th character of the string equals digit c (1-9), that means that at coordinate i there is a weight of mass c on the bar. 

Your task is, given the lever description, print if it will be in balance or not. Assume that the bar doesn't weight anything. Assume that the bar initially is in balance then all weights are simultaneously put on it. After that the bar either tilts to the left, or tilts to the right, or is in balance.


-----Input-----

The first line contains the lever description as a non-empty string s (3 ≤ |s| ≤ 10^6), consisting of digits (1-9) and characters "^" and "=". It is guaranteed that the line contains exactly one character "^". It is guaranteed that the pivot of the lever isn't located in any end of the lever bar.

To solve the problem you may need 64-bit integer numbers. Please, do not forget to use them in your programs.


-----Output-----

Print "left" if the given lever tilts to the left, "right" if it tilts to the right and "balance", if it is in balance.


-----Examples-----
Input
=^==

Output
balance

Input
9===^==1

Output
left

Input
2==^7==

Output
right

Input
41^52==

Output
balance



-----Note-----

As you solve the problem, you may find the following link useful to better understand how a lever functions: http://en.wikipedia.org/wiki/Lever.

The pictures to the examples:

 [Image] 

 [Image] 

 [Image] 

 $\Delta \Delta \Delta \Delta$

Difficulty: interview

Starter code:

Solutions:
s = input()
suc = 0
p = 0
kde = 0
for i in range(len(s)):
	c = s[i]
	if c == '^':
		kde = i
for i in range(len(s)):
	c = s[i]
	if '1' <= c <= '9':
		suc+=((kde-i)*int(c))
		p+=1
if suc < 0:
	print("right")
elif suc > 0:
	print("left")
else:
	print("balance")


string = list(input());

left = []
right = []
leftTotal = 0
rightTotal = 0
rightSide = False
pivot = -1
for i in range(len(string)):
	if string[i] == "^":
		pivot = i

for i in range(len(string)):
	if "1" <= string[i] <= "9":
		if rightSide == False:
			leftTotal += (int(string[i]) * (pivot-i))
		else:
			rightTotal += (int(string[i]) * (i-pivot))

if leftTotal > rightTotal:
	print("left")
elif leftTotal < rightTotal:
	print("right")
else:
	print("balance")


def main():
    string=input()
    fulcrum=string.index('^')
    mass_left=0
    mass_right=0
    for i in range(0,fulcrum):
        if string[i] != '=':
            mass_left+=int(string[i]) * (fulcrum-i)
    for i in range(fulcrum+1,len(string)):
        if string[i] != '=':
            mass_right+=int(string[i])*(i-fulcrum)

    if mass_left==mass_right:
        print ("balance")
        return
    if mass_left<mass_right:
        print("right")
        return
    if mass_right<mass_left:
        print("left")
        return
def __starting_point():
    main()
__starting_point()

x=input()
ind=x.index("^")

w1=x[0:ind]
w2=x[ind+1:]

left=0
right=0
for i in range (0,ind):
    if (x[i]== "="):
        left+=0
    else:
        left+=(int(x[i]))*(ind-i)

for j in range (ind+1,len(x)):
    if (x[j]=="="):
        right+=0
    else:
        right+=(int(x[j]))*(j-ind)

if (left>right):
    print ("left")
if (left<right):
    print ("right")
if (left==right):
    print ("balance")
    


s = input()

pivot_pos = 0
left_count = 0
right_count = 0

''''def is_number(s):
    try:
        float(s)
        return True
    except ValueError:
        return False
    try:
        import unicodedata
        unicodedata.numeric(s)
        return True
    except (TypeError, ValueError):
		return False'''

# Find the pivot
for i in range(len(s)):
	if s[i] == '^':
		pivot_pos = i 

# Solve left side
for i in range(pivot_pos):
	if s[i].isdigit() == True:
		left_count = left_count + (int(s[i]) * (pivot_pos - i))

# Solve left side
for i in range(pivot_pos, len(s)):
	if s[i].isdigit() == True:
		right_count = right_count + (int(s[i]) * (i - pivot_pos))

if left_count == right_count:
	print("balance")
elif left_count > right_count:
	print("left")
else:
	print("right")

def get_sum(side):
    result = 0
    
    for i in range(len(side)):
        result += side[i][0] * side[i][1]

    return result

def main():
    left = []
    right = []

    s = input()
    # s = "=^=="
    middle_pos = s.index("^")
    for i in range(len(s)):
        if s[i] == "=" or s[i] == "^":
            continue

        if i < middle_pos:
            left.append((int(s[i]), abs(middle_pos - i)))
        else:
            right.append((int(s[i]), abs(middle_pos - i)))

    left_sum = get_sum(left)
    right_sum = get_sum(right)

    if left_sum > right_sum:
        print("left")
    elif right_sum > left_sum:
        print("right")
    else:
        print("balance")

def __starting_point():
    main()

__starting_point()

# -*- coding: utf-8 -*-

def solve(s):
    sl, sr = s.split('^')
    left = sum([(i + 1) * int(c) for i, c in enumerate(reversed(sl)) if c.isdigit()])
    right = sum([(i + 1) * int(c) for i, c in enumerate(sr) if c.isdigit()])
    # print(left, right)
    if left > right:
        return "left"
    elif left == right:
        return "balance"
    else:
        return "right"
    

s = input()
print(solve(s))




def weight(s):
    w, i = 0, 1
    for c in s:
        if c != '=':
            w += i*int(c)
        i += 1
    return w

def main():
    line = input()
    l, r = line.split('^')
    l = weight(l[::-1])
    r = weight(r)
    if l > r:
        print('left')
    elif l < r:
        print('right')
    else:
        print('balance')

def __starting_point():
    main()
__starting_point()

s = input();

sumleft = 0;
sumrigth = 0;
sumtemp = 0;
pressed = 0;
step = 1;

for a in s :
    if (a == '^') :
        pressed = 1;
        step = 1;
    else :
        if (a == '=') : a = 0;
        else : a = int(a);

        if (pressed == 0) :
            sumleft += sumtemp + a;
            sumtemp += a;
        if (pressed == 1) :
            sumrigth += step * a;
            step = step + 1;


if (sumleft == sumrigth) :
    print ("balance");
if (sumleft > sumrigth) :
    print ("left");
if (sumleft < sumrigth) :
    print ("right");

a = input().strip()
n= len(a)
c = a.index('^')
l,r = 0,0
for i in range(c):
    if a[i].isdigit():
        l+=(c-i)*int(a[i])
for i in range(c+1,n):
    if a[i].isdigit():
        r+=(i-c)*int(a[i])
if l==r:
    print('balance')
elif l>r:
    print('left')
else:
    print('right')


m=input()
n = len(m)
k,o=0,0
for i in range(n):
    if m[i]=='^':
        l=i
for i in range(l):
    if m[i].isdigit():
        k+=int(m[i])*(l-i)
for i in range(l,n):
    if m[i].isdigit():
        o+=int(m[i])*(i-l)        
if k==o:
    print('balance')
elif k>o:
    print('left')
else:
    print('right')


t = input()
s, k = 0, t.find('^')
for i, j in enumerate(t[: k]):
    if j != '=': s += int(j) * (k - i)
for i, j in enumerate(t[k + 1: ], 1):
    if j != '=': s -= int(j) * i
if s > 0: print('left')
elif s < 0: print('right')
else: print('balance')

s=input()
x=s.index('^')
ans=0
for i in range(len(s)):
    if(s[i]=='=' or s[i]=='^'):
        continue
    if(i<x):
        ans+=int(s[i])*(x-i)
    else:
        ans-=int(s[i])*(i-x)
if(ans==0):
    print("balance")
elif(ans>0):
    print("left")
else:
    print("right")

s = input()
o = s.find('^')
a = list(int(s[i]) if s[i].isdigit() else 0 for i in range(len(s))) 
summa = 0
for i in range(len(s)):
    summa += (i-o) * a[i]
if summa < 0:
    print ('left')
elif summa == 0:
    print('balance')
else:
    print('right')

n = input()

zn = 0
wyn = 0
for i in range(len(n)):
    if n[i]=='^':
        zn = i
for i in range(len(n)):
    if n[i]!='^' and n[i]!='=':
        wyn += (zn-i)*int(n[i])

#print(wyn)
if wyn==0:
    print("balance")
elif wyn>0:
    print("left")
else:
    print("right")

sum=0
seq=input()
ind=seq.index("^")
for i in range(len(seq)):
    if seq[i].isdigit():
        sum+=(ind-i)*int(seq[i])
if sum==0:
    print("balance")
elif sum>0:
    print("left")
else:
    print("right")

__author__ = 'asmn'
s=input()
pivot=s.find('^')
res=sum(map(lambda i_x:int(i_x[1])*(i_x[0]-pivot) if i_x[1].isdigit() else 0,enumerate(s)))
print('left' if res<0 else 'right' if res>0 else 'balance')

s = str(input())
for cont in range(0,len(s)):
    if s[cont] == '^':
        pos = cont
        break

left = 0
right = 0
for d in range(0, pos):
    if s[d].isdigit():
        left += int(s[d])*(pos-d)

for d in range(pos+1,len(s)):
    if s[d].isdigit():
        right += int(s[d])*(d-pos)

if left == right:
    print('balance')
elif right> left:
    print('right')
else:
    print('left')

s=input()
n=len(s)
for i in range(n):
    if s[i]=='^': 
        x=i
        break
a=b=0
for i in range(x):
    if s[i]>='1' and s[i]<='9': a+=(int(s[i])-int('0'))*(x-i)
for i in range(x,n):
    if s[i]>='1' and s[i]<='9': b+=(int(s[i])-int('0'))*(i-x)
if a==b: print('balance')
else: print('left' if a>b else 'right')


s = input()
for i in range(len(s)):
    if s[i] == '^':
        o = i
l = s[0:o]
r = s[o+1:len(s)]
l_sum = r_sum = 0
for i in range(len(l)):
    if not (l[i] == '='):
        l_sum += int(l[i]) * (len(l) - i)
        
for i in range(len(r)):
    if not (r[i] == '='):
        r_sum += int(r[i]) * (i+1)# + 1)
if l_sum < r_sum:
    print('right')
elif l_sum > r_sum:
    print('left')
else:
    print('balance')

# -*- coding: utf-8 -*-

s1, s2 = input().split('^')
s1 = s1[::-1]

l1 = sum([(i+1) * int(s1[i]) for i in range(len(s1)) if s1[i] != '='])
l2 = sum([(i+1) * int(s2[i]) for i in range(len(s2)) if s2[i] != '='])

print('balance' if l1==l2 else 'left' if l1>l2 else 'right')


s=input().strip()
l=0
r=0
for i in range(len(s)):
    if s[i]=='^': p=i
for i in range(len(s)):
    if '1'<=s[i]<='9':
        if i>p:
            r+=int(s[i])*(i-p)
        else:
            l+=int(s[i])*(p-i)
if l>r:
    print('left')
elif l==r:
    print('balance')
else:
    print('right')

s = input().split("^")
s[0] = s[0][::-1]
m = lambda k: sum((ord(s[k][i]) - ord("0")) * (i + 1) for i in range(len(s[k])) if s[k][i] != "=")
a, b = m(0), m(1)
print("left" if a > b else "right" if a < b else "balance")