Wet Shark asked Rat Kwesh to generate three positive real numbers x, y and z, from 0.1 to 200.0, inclusive. Wet Krash wants to impress Wet Shark, so all generated numbers will have exactly one digit after the decimal point.

Wet Shark knows Rat Kwesh will want a lot of cheese. So he will give the Rat an opportunity to earn a lot of cheese. He will hand the three numbers x, y and z to Rat Kwesh, and Rat Kwesh will pick one of the these twelve options:  a_1 = x^{y}^{z};  a_2 = x^{z}^{y};  a_3 = (x^{y})^{z};  a_4 = (x^{z})^{y};  a_5 = y^{x}^{z};  a_6 = y^{z}^{x};  a_7 = (y^{x})^{z};  a_8 = (y^{z})^{x};  a_9 = z^{x}^{y};  a_10 = z^{y}^{x};  a_11 = (z^{x})^{y};  a_12 = (z^{y})^{x}. 

Let m be the maximum of all the a_{i}, and c be the smallest index (from 1 to 12) such that a_{c} = m. Rat's goal is to find that c, and he asks you to help him. Rat Kwesh wants to see how much cheese he gets, so he you will have to print the expression corresponding to that a_{c}.

 


-----Input-----

The only line of the input contains three space-separated real numbers x, y and z (0.1 ≤ x, y, z ≤ 200.0). Each of x, y and z is given with exactly one digit after the decimal point.


-----Output-----

Find the maximum value of expression among x^{y}^{z}, x^{z}^{y}, (x^{y})^{z}, (x^{z})^{y}, y^{x}^{z}, y^{z}^{x}, (y^{x})^{z}, (y^{z})^{x}, z^{x}^{y}, z^{y}^{x}, (z^{x})^{y}, (z^{y})^{x} and print the corresponding expression. If there are many maximums, print the one that comes first in the list. 

x^{y}^{z} should be outputted as x^y^z (without brackets), and (x^{y})^{z} should be outputted as (x^y)^z (quotes for clarity). 


-----Examples-----
Input
1.1 3.4 2.5

Output
z^y^x

Input
2.0 2.0 2.0

Output
x^y^z

Input
1.9 1.8 1.7

Output
(x^y)^z

Difficulty: interview

Starter code:

Solutions:
from math import log
from decimal import Decimal

s = ['x^y^z', 'x^z^y', '(x^y)^z', 'y^x^z', 'y^z^x', '(y^x)^z', 'z^x^y', 'z^y^x', '(z^x)^y']

x, y, z = list(map(Decimal, input().split()))

f = []
f += [(Decimal(log(x)) * (y ** z),  0)]
f += [(Decimal(log(x)) * (z ** y), -1)]
f += [(Decimal(log(x)) * (y *  z), -2)]
f += [(Decimal(log(y)) * (x ** z), -3)]
f += [(Decimal(log(y)) * (z ** x), -4)]
f += [(Decimal(log(y)) * (x *  z), -5)]
f += [(Decimal(log(z)) * (x ** y), -6)]
f += [(Decimal(log(z)) * (y ** x), -7)]
f += [(Decimal(log(z)) * (x *  y), -8)]

f.sort()

print(s[-f[-1][1]])


from math import *
from decimal import *

def p1(x, y, z):
	return Decimal(log(x, 2)) * Decimal(Decimal(y) ** Decimal(z))
def p2(x, y, z):
	return Decimal(log(x, 2)) * Decimal(Decimal(y) * Decimal(z))
x, y, z = list(map(float, input().split()))
f = [p1(x, y, z), p1(x, z, y), p2(x, y, z), p2(x, z, y), p1(y, x, z), p1(y, z, x), 
p2(y, x, z), p2(y, z, x), p1(z, x, y), p1(z, y, x), p2(z, x, y), p2(z, y, x)]
ans = ['x^y^z', 'x^z^y', '(x^y)^z', '(x^z)^y', 'y^x^z', 'y^z^x', '(y^x)^z', '(y^z)^x','z^x^y', 'z^y^x', '(z^x)^y', '(z^y)^x']
x = 0
eps = 1e-6
for i in range(0, 12):
	if (f[i] > f[x] + Decimal(eps)):
		x = i
print(ans[x])


import math
from decimal import *
getcontext().prec = 1024
x, y, z = list(map(Decimal, input().split(" ")))
l = lambda t: Decimal(math.log(t))
a = [
	(lambda: y ** z * l(x), "x^y^z"),
	(lambda: z ** y * l(x), "x^z^y"),
	(lambda: y * z * l(x), "(x^y)^z"),

	(lambda: x ** z * l(y), "y^x^z"),
	(lambda: z ** x * l(y), "y^z^x"),
	(lambda: x * z * l(y), "(y^x)^z"),

	(lambda: x ** y * l(z), "z^x^y"),
	(lambda: y ** x * l(z), "z^y^x"),
	(lambda: x * y * l(z), "(z^x)^y"),
]
m = -1
ans = ""
for calc, exp in a:
	q = calc()
	if q > m:
		m = q
		ans = exp
print(ans)


from math import log
from decimal import Decimal

x, y, z = [Decimal(x) for x in input().split()]

variants = sorted([
    ((y ** z) * Decimal(log(x)), -1),
    ((z ** y) * Decimal(log(x)), -2),
    (y * z * Decimal(log(x)), -3),
    ((x ** z) * Decimal(log(y)), -5),
    ((z ** x) * Decimal(log(y)), -6),
    (x * z * Decimal(log(y)), -7),
    ((x ** y) * Decimal(log(z)), -9),
    ((y ** x) * Decimal(log(z)), -10),
    (x * y * Decimal(log(z)), -11)
])

expressions = [
    "x^y^z", "x^z^y", "(x^y)^z", "(x^z)^y",
    "y^x^z", "y^z^x", "(y^x)^z", "(y^z)^x",
    "z^x^y", "z^y^x", "(z^x)^y", "(z^y)^x"
]

print(expressions[abs(variants[-1][1]) - 1])


from decimal import *
getcontext().prec = 500
x, y, z = map(float, input().split())
x = Decimal(x)
y = Decimal(y)
z = Decimal(z)
a = [Decimal(0) for i in range(12)]
a[0] = ((Decimal(x).log10()) * Decimal(Decimal(y) ** Decimal(z)))
a[1] = ((Decimal(x).log10()) * Decimal(Decimal(z) ** Decimal(y)))
a[2] = ((Decimal(x).log10()) * Decimal(Decimal(y) * Decimal(z)))
a[3] = ((Decimal(x).log10()) * Decimal(Decimal(y) * Decimal(z)))
a[4] = ((Decimal(y).log10()) * Decimal(Decimal(x) ** Decimal(z)))
a[5] = ((Decimal(y).log10()) * Decimal(Decimal(z) ** Decimal(x)))
a[6] = ((Decimal(y).log10()) * Decimal(Decimal(x) * Decimal(z)))
a[7] = ((Decimal(y).log10()) * Decimal(Decimal(x) * Decimal(z)))
a[8] = ((Decimal(z).log10()) * Decimal(Decimal(x) ** Decimal(y)))
a[9] = ((Decimal(z).log10()) * Decimal(Decimal(y) ** Decimal(x)))
a[10] = ((Decimal(z).log10()) * Decimal(Decimal(x) * Decimal(y)))
a[11] = ((Decimal(z).log10()) * Decimal(Decimal(x) * Decimal(y)))
maxx = a[0]
for i in range(12):
	if a[i] > maxx:
		maxx = a[i]
s = ["" for i in range(12)]
s[0] = "x^y^z"
s[1] = "x^z^y"
s[2] = "(x^y)^z"
s[3] = "(x^z)^y"
s[4] = "y^x^z"
s[5] = "y^z^x"
s[6] = "(y^x)^z"
s[7] = "(y^z)^x"
s[8] = "z^x^y"
s[9] = "z^y^x"
s[10] = "(z^x)^y"
s[11] = "(z^y)^x"
for i in range(12):
	if a[i] == maxx:
		print (s[i])
		break

from decimal import *

getcontext().prec = 333

a,b,c = input().split()

x = Decimal(a)
y = Decimal(b)
z = Decimal(c)

l = [
    (x).ln()*(y**z),
    (x).ln()*(z**y),
    (x**y).ln()*z,
    (x**z).ln()*y,
    (y).ln()*(x**z),
    (y).ln()*(z**x),
    (y**x).ln()*z,
    (y**z).ln()*x,
    (z).ln()*(x**y),
    (z).ln()*(y**x),
    (z**x).ln()*y,
    (z**y).ln()*x
]

#getcontext().prec = 300

#l = [i.quantize(Decimal('.' + '0'*250 + '1'), rounding=ROUND_DOWN) for i in l]

#print(l)

m = max(l)

s = [
    "x^y^z",
    "x^z^y", 
    "(x^y)^z", 
    "(x^z)^y", 
    "y^x^z",
    "y^z^x",
    "(y^x)^z",
    "(y^z)^x",
    "z^x^y",
    "z^y^x",
    "(z^x)^y",
    "(z^y)^x"
]

#for t in l:
#    print(t)


i = 0
for j in range(12):
    #print(abs(l[j]-m))
    if abs(l[j]-m) < Decimal('.' + '0'*100 + '1'):
        i = j
        break

print(s[i])

from math import log
from decimal import Decimal


def t1(a, b, c):
    return int((Decimal(log(a)) * (b ** c)) / Decimal(0.000000000001))


def t2(a, b, c):
    return int((Decimal(log(a)) * b * c) / Decimal(0.000000000001))


def solve():
    x, y, z = list(map(Decimal, input().split()))

    a = [0.0] * 12

    a[0] = t1(x, y, z), 0, 'x^y^z'
    a[1] = t1(x, z, y), -1, 'x^z^y'
    a[2] = t2(x, y, z), -2, '(x^y)^z'
    a[3] = t2(x, z, y), -3, '(x^z)^y'

    a[4] = t1(y, x, z), -4, 'y^x^z'
    a[5] = t1(y, z, x), -5, 'y^z^x'
    a[6] = t2(y, x, z), -6, '(y^x)^z'
    a[7] = t2(y, z, x), -7, '(y^z)^x'

    a[8] = t1(z, x, y), -8, 'z^x^y'
    a[9] = t1(z, y, x), -9, 'z^y^x'
    a[10] = t2(z, x, y), -10, '(z^x)^y'
    a[11] = t2(z, y, x), -11, '(z^y)^x'

    v, i, f = max(a)

    print(f)


def __starting_point():
    solve()

__starting_point()

from decimal import *

x, y, z = list(map(Decimal, input().split(' ')))

getcontext().prec = 100

a = [0] * 9
a[0] = x.ln() * (y ** z)
a[1] = x.ln() * (z ** y)
a[2] = x.ln() * y * z
a[3] = y.ln() * (x ** z)
a[4] = y.ln() * (z ** x)
a[5] = y.ln() * x * z
a[6] = z.ln() * (x ** y)
a[7] = z.ln() * (y ** x)
a[8] = z.ln() * x * y

mx = 0

for i in range(9):
    if abs(a[i] - a[mx]) > Decimal(10) ** (-50) and a[i] > a[mx]:
        mx = i

s = [""] * 9
s[0] = "x^y^z"
s[1] = "x^z^y"
s[2] = "(x^y)^z"
s[3] = "y^x^z"
s[4] = "y^z^x"
s[5] = "(y^x)^z"
s[6] = "z^x^y"
s[7] = "z^y^x"
s[8] = "(z^x)^y"

print(s[mx])


import math
import decimal
output= [
    'x^y^z', # 0
	'x^z^y', # 1
	'(x^y)^z', # 2
	'(x^z)^y', # 3
    
	'y^x^z', # 4
	'y^z^x', # 5
	'(y^x)^z', # 6
	'(y^z)^x', # 7
    
	'z^x^y', # 8
	'z^y^x', # 9
	'(z^x)^y', # 10
	'(z^y)^x' # 11
]

x,y,z=map(decimal.Decimal,input().split())


a=[(decimal.Decimal(math.log(x))*(y**z),0)]
a+=[(decimal.Decimal(math.log(x))*(z**y),1)]
a+=[(decimal.Decimal(math.log(x))*y*z,2)]

a+=[(decimal.Decimal(math.log(y))*(x**z),4)]
a+=[(decimal.Decimal(math.log(y))*(z**x),5)]
a+=[(decimal.Decimal(math.log(y))*x*z,6)]

a+=[(decimal.Decimal(math.log(z))*(x**y),8)]
a+=[(decimal.Decimal(math.log(z))*(y**x),9)]
a+=[(decimal.Decimal(math.log(z))*x*y,10)]

ret=output[0]
# print(a[0][0])
cmp=a[0][0]
for i in range(0,9):
    if a[i][0]>cmp:
        cmp=a[i][0]
        ret=output[a[i][1]]

print(ret)

import math
import decimal
output= [
    'x^y^z', # 0
	'x^z^y', # 1
	'(x^y)^z', # 2
	'(x^z)^y', # 3

	'y^x^z', # 4
	'y^z^x', # 5
	'(y^x)^z', # 6
	'(y^z)^x', # 7

	'z^x^y', # 8
	'z^y^x', # 9
	'(z^x)^y', # 10
	'(z^y)^x' # 11
]

x,y,z=map(decimal.Decimal,input().split())

a=[]
a+=[(decimal.Decimal(math.log(x))*(y**z),0)]
a+=[(decimal.Decimal(math.log(x))*(z**y),-1)]
a+=[(decimal.Decimal(math.log(x))*y*z,-2)]

a+=[(decimal.Decimal(math.log(y))*(x**z),-4)]
a+=[(decimal.Decimal(math.log(y))*(z**x),-5)]
a+=[(decimal.Decimal(math.log(y))*x*z,-6)]

a+=[(decimal.Decimal(math.log(z))*(x**y),-8)]
a+=[(decimal.Decimal(math.log(z))*(y**x),-9)]
a+=[(decimal.Decimal(math.log(z))*x*y,-10)]


# print(a)
a.sort()
# print(a)

print(output[-a[8][1]])

from math import log, inf
from itertools import product, permutations
def comp_key(p, A, mode):
    a = log(A[p[0][1]])*A[p[0][2]] if p[1] else log(A[p[0][1]]) + log(A[p[0][2]])
    k = A[p[0][0]] if mode else 1/A[p[0][0]]
    return a + log(log(k)) if k > 1 else -inf

def solve(A):
    mode = any((x > 1 for x in A))
    c = (max if mode else min)(((x,y) for y in [True, False] for x in permutations(list(range(3)))), key = lambda p: comp_key(p, A, mode))
    k = 'xyz'
    return ('{0}^{1}^{2}' if c[1] else '({0}^{1})^{2}').format(k[c[0][0]], k[c[0][1]], k[c[0][2]])

A = [float(s) for s in input().split()]
print(solve(A))



import math
import decimal
output= [
    'x^y^z', # 0
	'x^z^y', # 1
	'(x^y)^z', # 2
	'(x^z)^y', # 3

	'y^x^z', # 4
	'y^z^x', # 5
	'(y^x)^z', # 6
	'(y^z)^x', # 7

	'z^x^y', # 8
	'z^y^x', # 9
	'(z^x)^y', # 10
	'(z^y)^x' # 11
]

x,y,z=map(decimal.Decimal,input().split())

a=[]
a+=[(decimal.Decimal(math.log(x))*(y**z),0)]
a+=[(decimal.Decimal(math.log(x))*(z**y),-1)]
a+=[(decimal.Decimal(math.log(x))*y*z,-2)]

a+=[(decimal.Decimal(math.log(y))*(x**z),-4)]
a+=[(decimal.Decimal(math.log(y))*(z**x),-5)]
a+=[(decimal.Decimal(math.log(y))*x*z,-6)]

a+=[(decimal.Decimal(math.log(z))*(x**y),-8)]
a+=[(decimal.Decimal(math.log(z))*(y**x),-9)]
a+=[(decimal.Decimal(math.log(z))*x*y,-10)]


# print(a)
# print(a)

print(output[-max(a)[1]])

from math import log
from decimal import Decimal

def a1(x, y, z):
    return (y ** z) * Decimal(log(x))

def s1(x, y, z):
    return "x^y^z"

def a2(x, y, z):
    return (z ** y) * Decimal(log(x))

def s2(x, y, z):
    return "x^z^y"

def a3(x, y, z):
    return (y * z) * Decimal(log(x))

def s3(x, y, z):
    return "(x^y)^z"

def a4(x, y, z):
    return (y * z) * Decimal(log(x))

def s4(x, y, z):
    return "(x^z)^y"

def a5(x, y, z):
    return (x ** z) * Decimal(log(y))

def s5(x, y, z):
    return "y^x^z"

def a6(x, y, z):
    return (z ** x) * Decimal(log(y))

def s6(x, y, z):
    return "y^z^x"

def a7(x, y, z):
    return (x * z) * Decimal(log(y))

def s7(x, y, z):
    return "(y^x)^z"

def a8(x, y, z):
    return (z * x) * Decimal(log(y))

def s8(x, y, z):
    return "(y^z)^x"

def a9(x, y, z):
    return (x ** y) * Decimal(log(z))

def s9(x, y, z):
    return "z^x^y"

def a10(x, y, z):
    return (y ** x) * Decimal(log(z))

def s10(x, y, z):
    return "z^y^x"

def a11(x, y, z):
    return (x * y) * Decimal(log(z))

def s11(x, y, z):
    return "(z^x)^y"

def a12(x, y, z):
    return (y * x) * Decimal(log(z))

def s12(x, y, z):
    return "(z^y)^x"

x, y, z = list(map(Decimal, input().split()))
ans = s1(x, y, z)
a = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12]
s = [s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12]
max = a1(x, y, z)
for i in range (12):
    if max < a[i](x, y, z):
        ans = s[i](x, y, z)
        max = a[i](x, y, z)
print(ans)


from decimal import *
getcontext().prec = 100
x, y ,z = map(Decimal,input().split())

op = ('x^y^z', 'x^z^y', '(x^y)^z', 'y^x^z', 'y^z^x', \
        '(y^x)^z', 'z^x^y','z^y^x','(z^x)^y')

arr = [[(y ** z) * x.ln() ,9], [(z ** y) * x.ln(), 8], [(z * y) * x.ln(),7], \
    [(x ** z) * y.ln(), 6], [(z ** x) * y.ln(), 5], [(x * z) * y.ln() ,4], \
    [(x ** y) * z.ln(),3], [(y ** x) * z.ln(), 2], [(x * y) * z.ln() ,1]]

ans = arr[0]
for i in arr:
    if i[0]>ans[0]:
        ans = i

print(op[-ans[1]])

from math import log
def lbig(x, y, z, f):
    if x == 1.0:
        return 0.0
    
    w = 1.0
    if x < 1.0:
        x = 1.0/x

    if f == True:
        return w * (z * log(y) + log(log(x)))
    
    return w * (log(y) + log(z) + log(log(x)))

def rets(x, y, z, xs, ys, zs, n):
    xss = [
    (lbig(x, y, z, True), xs+'^'+ys+'^'+zs,n+1),
    (lbig(x, z, y, True), xs+'^'+zs+'^'+ys,n+2),
    (lbig(x, y, z, False), '('+xs+'^'+ys+')^'+zs,n+3),
    (lbig(x, z, y, False), '('+xs+'^'+zs+')^'+ys,n+4),
    ]
    return xss

x, y, z = list(map(float, input().split()))
ans = ''
if x <= 1.0 and y <= 1.0 and z <= 1.0:
    xss = [
    (x**(y**z), 'x^y^z',1),
    (x**(z**y), 'x^z^y',2),
    (x**(y*z), '(x^y)^z',3),
    (x**(z*y), '(x^z)^y',4),
    ]
    yss = [
    (y**(x**z), 'y^x^z',5),
    (y**(z**x), 'y^z^x',6),
    (y**(x*z), '(y^x)^z',7),
    (y**(z*x), '(y^z)^x',8),
    ]
    zss = [
    (z**(x**y), 'z^x^y',9),
    (z**(y**x), 'z^y^x',10),
    (z**(x*y), '(z^x)^y',11),
    (z**(y*x), '(z^y)^x',12),
    ]
    anss = sorted(xss+yss+zss, key=lambda x: (x[0], -x[2]))
    ans = anss[-1][1]
else:
    xss = []
    yss = []
    zss = []
    if x > 1.0:
        xss = rets(x, y, z, 'x', 'y', 'z', 0)
    if y > 1.0:
        yss = rets(y, x, z, 'y', 'x', 'z', 4)
    if z > 1.0:
        zss = rets(z, x, y, 'z', 'x', 'y', 8)
    anss = sorted(xss+yss+zss, key=lambda x: (x[0],-x[2]))
    # print(anss)
    ans = anss[-1][1]
    
print(ans)







from math import log
from decimal import Decimal

output = ["x^y^z", "x^z^y", "(x^y)^z", "(x^z)^y)", "y^x^z", "y^z^x", "(y^x)^z", "(y^z)^x", "z^x^y", "z^y^x", "(z^x)^y", "(z^y)^x"]

x, y, z = list(map(Decimal, input().split()))

val = [	(Decimal(log(x)) * (y ** z), 0),
		(Decimal(log(x)) * (z ** y), -1),
		(Decimal(log(x)) * (y * z), -2),
		(Decimal(log(x)) * (y ** z), -3),
		(Decimal(log(y)) * (x ** z), -4),
		(Decimal(log(y)) * (z ** x), -5),
		(Decimal(log(y)) * (x * z), -6),
		(Decimal(log(y)) * (x * z), -7),
		(Decimal(log(z)) * (x ** y), -8),
		(Decimal(log(z)) * (y ** x), -9),
		(Decimal(log(z)) * (x * y), -10),
		(Decimal(log(z)) * (x * y), -11)
		]

print(output[-max(val)[1]])


from math import log10
from decimal import Decimal

ans = ["x^y^z", "x^z^y", "(x^y)^z", "(x^z)^y)", "y^x^z", "y^z^x", "(y^x)^z", "(y^z)^x", "z^x^y", "z^y^x", "(z^x)^y", "(z^y)^x"]

x, y, z = list(map(Decimal, input().split()))

val = [ (Decimal(log10(x)) * (y ** z), -0),
        (Decimal(log10(x)) * (z ** y), -1),
        (Decimal(log10(x)) * (y * z), -2),
        (Decimal(log10(x)) * (y ** z), -3),
        (Decimal(log10(y)) * (x ** z), -4),
        (Decimal(log10(y)) * (z ** x), -5),
        (Decimal(log10(y)) * (x * z), -6),
        (Decimal(log10(y)) * (x * z), -7),
        (Decimal(log10(z)) * (x ** y), -8),
        (Decimal(log10(z)) * (y ** x), -9),
        (Decimal(log10(z)) * (x * y), -10),
        (Decimal(log10(z)) * (x * y), -11)
        ]

print(ans[-max(val)[1]])


import math

s = ['x^y^z',
     'x^z^y',
     '(x^y)^z',
     '(x^z)^y',
     'y^x^z',
     'y^z^x',
     '(y^x)^z',
     '(y^z)^x',
     'z^x^y',
     'z^y^x',
     '(z^x)^y',
     '(z^y)^x']

x, y, z = map(float, input().split())

ma = float('-inf')
c = -1

if x > 1:
    if ma < z * math.log(y) + math.log(math.log(x)):
        ma = z * math.log(y) + math.log(math.log(x))
        c = 0
    
    if ma < y * math.log(z) + math.log(math.log(x)):
        ma = y * math.log(z) + math.log(math.log(x))
        c = 1

    if ma < math.log(y) + math.log(z) + math.log(math.log(x)):
        ma = math.log(y) + math.log(z) + math.log(math.log(x))
        c = 2

if y > 1:
    if ma < z * math.log(x) + math.log(math.log(y)):
        ma = z * math.log(x) + math.log(math.log(y))        
        c = 4
    
    if ma < x * math.log(z) + math.log(math.log(y)):
        ma = x * math.log(z) + math.log(math.log(y))
        c = 5

    if ma < math.log(x) + math.log(z) + math.log(math.log(y)):
        ma = math.log(x) + math.log(z) + math.log(math.log(y))
        c = 6

if z > 1:
    if ma < y * math.log(x) + math.log(math.log(z)):
        ma = y * math.log(x) + math.log(math.log(z))        
        c = 8
    
    if ma < x * math.log(y) + math.log(math.log(z)):
        ma = x * math.log(y) + math.log(math.log(z))
        c = 9

    if ma < math.log(x) + math.log(y) + math.log(math.log(z)):
        ma = math.log(x) + math.log(y) + math.log(math.log(z))
        c = 10

# if max(x , y, z) <= 1
if c == -1:
    if ma < x ** (y ** z):
        ma = x ** (y ** z)
        c = 0
    
    if ma < x ** (z ** y):
        ma = x ** (z ** y)
        c = 1
    
    if ma < (x ** y) ** z:
        ma = (x ** y) ** z
        c = 2
    
    if ma < y ** (x ** z):
        ma = y ** (x ** z)
        c = 4
    
    if ma < y ** (z ** x):
        ma = y ** (z ** x)
        c = 5
    
    if ma < (y ** x) ** z:
        ma = (y ** x) ** z
        c = 6
    
    if ma < z ** (x ** y):
        ma = z ** (x ** y)
        c = 8
    
    if ma < z ** (y ** x):
        ma = z ** (y ** x)
        c = 9
    
    if ma < (z ** x) ** y:
        ma = (z ** x) ** y
        c = 10
        
print(s[c])

import math
from decimal import *
p,q,r=x,y,z=input().split()
x=float(x)
y=float(y)
z=float(z)
if(x>1 and y>1 and z>1):
	p=z*math.log(y)+math.log(math.log(x))
	ans="x^y^z"
	max=p
	p=y*math.log(z)+math.log(math.log(x))
	if(p>max):
		max=p
		ans="x^z^y"
	p=math.log(y)+math.log(z)+math.log(math.log(x))
	if(p>max):
		max=p
		ans="(x^y)^z"
	p=z*math.log(x)+math.log(math.log(y))
	if(p>max):
		max=p
		ans="y^x^z"
	p=x*math.log(z)+math.log(math.log(y))
	if(p>max):
		max=p
		ans="y^z^x"
	p=math.log(x)+math.log(z)+math.log(math.log(y))
	if(p>max):
		max=p
		ans="(y^x)^z"
	p=y*math.log(x)+math.log(math.log(z))
	if(p>max):
		max=p
		ans="z^x^y"
	p=x*math.log(y)+math.log(math.log(z))
	if(p>max):
		max=p
		ans="z^y^x"
	p=math.log(x)+math.log(y)+math.log(math.log(z))
	if(p>max):
		max=p
		ans="(z^x)^y"
else:
	if(not(x<1 and y<1 and z<1)):
		x=Decimal(p)
		y=Decimal(q)
		z=Decimal(r)
	p=x**(y**z)
	max=p;
	ans="x^y^z"
	p=x**(z**y)
	if(p>max):
		max=p
		ans="x^z^y"
	p=x**(y*z)
	if(p>max):
		max=p
		ans="(x^y)^z"
	p=y**(x**z)
	if(p>max):
		max=p
		ans="y^x^z"
	p=y**(z**x)
	if(p>max):
		max=p
		ans="y^z^x"
	p=y**(x*z)
	if(p>max):
		max=p
		ans="(y^x)^z"
	p=z**(x**y)
	if(p>max):
		max=p
		ans="z^x^y"
	p=z**(y**x)
	if(p>max):
		max=p
		ans="z^y^x"
	p=z**(x*y)
	if(p>max):
		max=p
		ans="(z^x)^y"
print(ans)


import math

slog = lambda x: math.log(math.log(x))
a = [float(n) for n in input().split()]
r = ([(lambda x, y, z: -10.0**10 if math.log(x) <= 0 else slog(x) + z * math.log(y), "x^y^z"),
      (lambda x, y, z:-10.0**10 if math.log(x) <= 0 else slog(x) + y * math.log(z), "x^z^y"),
      (lambda x, y, z:-10.0**10 if math.log(x) <= 0 else slog(x) + math.log(y) + math.log(z), "(x^y)^z"),
      (lambda x, y, z:-10.0**10 if math.log(y) <= 0 else slog(y) + z * math.log(x), "y^x^z"),
      (lambda x, y, z:-10.0**10 if math.log(y) <= 0 else slog(y) + x * math.log(z), "y^z^x"),
      (lambda x, y, z:-10.0**10 if math.log(y) <= 0 else slog(y) + math.log(z) +  math.log(x), "(y^x)^z"),
      (lambda x, y, z:-10.0**10 if math.log(z) <= 0 else slog(z) + y * math.log(x), "z^x^y"),
      (lambda x, y, z:-10.0**10 if math.log(z) <= 0 else slog(z) + x * math.log(y), "z^y^x"),
      (lambda x, y, z:-10.0**10 if math.log(z) <= 0 else slog(z) +  math.log(y) + math.log(x), "(z^x)^y")])
rr = ([(lambda x, y, z: y**z * math.log(x), "x^y^z"),
      (lambda x, y, z: z**y * math.log(x), "x^z^y"),
      (lambda x, y, z: math.log(x) * y * z, "(x^y)^z"),
      (lambda x, y, z: math.log(y) * x**z ,"y^x^z"),
      (lambda x, y, z: math.log(y)*z**x, "y^z^x"),
      (lambda x, y, z: math.log(y) * z * x, "(y^x)^z"),
      (lambda x, y, z: math.log(z) * x ** y, "z^x^y"),
      (lambda x, y, z: math.log(z)* y ** x, "z^y^x"),
      (lambda x, y, z: math.log(z) * x * y, "(z^x)^y")])
exp = ""
best = -10**50
if all([x <= 1.0 for x in a]):
	for f, e in rr:
		val = f(a[0], a[1],  a[2])
		if val - best > 1e-10:
			best = val
			exp = e

else:
    for f, e in r:
        val = f(a[0], a[1], a[2])
        if val > best:
            best = val
            exp = e

print (exp)

from math import log
from decimal import *

x, y, z = map(Decimal, input().split())
logd = lambda x: Decimal(log(x))
r = ([(lambda x, y, z: y**z * logd(x), "x^y^z"),
      (lambda x, y, z: z**y * logd(x), "x^z^y"),
      (lambda x, y, z: logd(x) * y * z, "(x^y)^z"),
      (lambda x, y, z: logd(y) * x**z ,"y^x^z"),
      (lambda x, y, z: logd(y) * z**x, "y^z^x"),
      (lambda x, y, z: logd(y) * z * x, "(y^x)^z"),
      (lambda x, y, z: logd(z) * x ** y, "z^x^y"),
      (lambda x, y, z: logd(z)* y ** x, "z^y^x"),
      (lambda x, y, z: logd(z) * x * y, "(z^x)^y")])
exp = ""
best = -10**50
for f, e in r:
	val = f(x, y, z)
	if val > best:
		best = val
		exp = e

print (exp)

from math import log
from decimal import *

x, y, z = map(Decimal, input().split())
logd = lambda x: Decimal(log(x))
r = sorted([(-logd(x) * y**z, "x^y^z"),
      (-logd(x) * z**y, "x^z^y"),
      (-logd(x) * y * z, "(x^y)^z"),
      (-logd(y) * x**z ,"y^x^z"),
      (-logd(y) * z**x, "y^z^x"),
      (-logd(y) * z * x, "(y^x)^z"),
      (-logd(z) * x ** y, "z^x^y"),
      (-logd(z)* y ** x, "z^y^x"),
      (-logd(z) * x * y, "(z^x)^y")], key=lambda a: a[0])
print (r[0][1])

from math import log
from decimal import *

x, y, z = map(Decimal, input().split())
logd = lambda x: Decimal(log(x))
r = sorted([(-logd(x) * y**z, "x^y^z"),
      (-logd(x) * z**y, "x^z^y"),
      (-logd(x) * y * z, "(x^y)^z"),
      (-logd(y) * x**z ,"y^x^z"),
      (-logd(y) * z**x, "y^z^x"),
      (-logd(y) * z * x, "(y^x)^z"),
      (-logd(z) * x ** y, "z^x^y"),
      (-logd(z)* y ** x, "z^y^x"),
      (-logd(z) * x * y, "(z^x)^y")], key=lambda a: a[0])
print (r[0][1])

from decimal import Decimal
x,y,z = map(Decimal, input().split())
a = ['x^y^z', 'x^z^y', '(x^y)^z', 'y^x^z', 'y^z^x', '(y^x)^z',
         'z^x^y', 'z^y^x', '(z^x)^y']
f = [y ** z * x.ln(), z ** y * x.ln(), y * z * x.ln(), x ** z * y.ln(),
       z ** x * y.ln(), x * z * y.ln(), x ** y * z.ln(), y ** x * z.ln(),
       x * y * z.ln()]
max, res = -10**18, 0
for i, j in enumerate(f):
    if j > max:
        max, res = j, i
print(a[res])

from decimal import *
from math import log

def d_log(x):
    return Decimal(log(x))

def __starting_point():

    #getcontext().prec = 1024
    x , y , z = map( Decimal , input().split() )
    exps = [ ( (y**z)*d_log(x), 0),
             ( (z**y)*d_log(x), 1),
             ( z*y*d_log(x), 2),
             #( y*d_log(x**z), 3),
             ( (x**z)*d_log(y), 4),
             ( (z**x)*d_log(y), 5),
             ( z*x*d_log(y), 6),
             #( x*d_log(y**z), 7),
             ( (x**y)*d_log(z), 8),
             ( (y**x)*d_log(z), 9),
             ( y*x*d_log(z), 10),
             #( x*d_log(z**y), 11),
            ]

    exps.sort(key=lambda e:(-e[0],e[1]))
    #for r,index in exps:
    #    print( "exp(", index, ") =" , r )

    c = exps[0][1]

    res = [ "x^y^z",   "x^z^y",    "(x^y)^z",   "(x^z)^y",
            "y^x^z",   "y^z^x",    "(y^x)^z",   "(y^z)^x",
            "z^x^y",   "z^y^x",    "(z^x)^y",   "(z^y)^x"
           ]
    print( res[c] )
__starting_point()