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: VERY_HARD
Tags: Complete search

Mathematics

Constructive algorithms
Skill types: Complete search

Starter code:

Solutions:
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 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)


def solve():
	m = 0
	c = ''
	s = list(map(float, input().split()))
	f = ['x', 'y', 'z']
	d = solve2(s.copy())
	if d:
		return print(d)
	s2 = sorted(s)
	flag = False
	if s2[0] < 2:
		s2 = s2[1:] + s2[:1]
	if s2[0] < 2:
		(s2[0], s2[1]) = (s2[1], s2[0])
	try:
		if s2[1] * s2[2] > s2[1] ** s2[2]:
			flag = True
	except:
		pass
	ans = []
	used = [0] * 3
	for i in range(3):
		j = s.index(s2[i])
		while used[j]:
			j = s.index(s2[i], j + 1, 3)
		ans.append(f[j])
		used[j] = 1
	if flag:
		if f.index(ans[2]) < f.index(ans[1]):
			(ans[1], ans[2]) = (ans[2], ans[1])
		print(f'({ans[0]}^{ans[1]})^{ans[2]}')
	else:
		print(f'{ans[0]}^{ans[1]}^{ans[2]}')

def solve2(s):
	m = 0
	c = ''
	f = ['x', 'y', 'z']
	for i in range(3):
		for j in range(2):
			for e in range(3):
				if e == i:
					continue
				cur = 0
				try:
					if j == 0:
						cur = s[i] ** s[e] ** s[3 ^ e ^ i]
						if cur > m:
							m = cur
							c = f'{f[i]}^{f[e]}^{f[3 ^ e ^ i]}'
					else:
						cur = s[i] ** (s[e] * s[3 ^ e ^ i])
						if cur > m:
							m = cur
							c = f'({f[i]}^{f[e]})^{f[3 ^ e ^ i]}'
				except OverflowError:
					return ''
	return c
solve()


from math import log
from decimal import Decimal

def t1(a, b, c):
	return int(Decimal(log(a)) * b ** c / Decimal(1e-12))

def t2(a, b, c):
	return int(Decimal(log(a)) * b * c / Decimal(1e-12))

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 math import log2 as log

def gen(x, y, z):
	return ['{}^{}^{}'.format(x, y, z), '{}^{}^{}'.format(x, z, y), '({}^{})^{}'.format(x, y, z), '({}^{})^{}'.format(x, z, y)]

def f(x):
	return log(x)

def calc1(x, y, z):
	return [z * f(y) + f(f(x)), y * f(z) + f(f(x)), f(y * z) + f(f(x)), f(z * y) + f(f(x))]

def calc2(x, y, z):
	return [x ** y ** z, x ** z ** y, x ** (y * z), x ** (z * y)]

def build(x, y, z):
	(s1, s2) = ([], [])
	if x > 1:
		s1 += gen('x', 'y', 'z')
		s2 += calc1(x, y, z)
	if y > 1:
		s1 += gen('y', 'x', 'z')
		s2 += calc1(y, x, z)
	if z > 1:
		s1 += gen('z', 'x', 'y')
		s2 += calc1(z, x, y)
	return (s1, s2)

def build2(x, y, z):
	(s1, s2) = ([], [])
	s1 += gen('x', 'y', 'z')
	s2 += calc2(x, y, z)
	s1 += gen('y', 'x', 'z')
	s2 += calc2(y, x, z)
	s1 += gen('z', 'x', 'y')
	s2 += calc2(z, x, y)
	return (s1, s2)
(x, y, z) = [float(t) for t in input().strip().split()]
(s1, s2) = build(x, y, z)
if len(s1) == 0:
	(s1, s2) = build2(x, y, z)
print(s1[s2.index(max(s2))])


from decimal import *
from math import log
getcontext().prec = 500
(x, y, z) = map(Decimal, input().split())
(a, l) = ([], [])
l.append('')
l.append('x^y^z')
l.append('x^z^y')
l.append('(x^y)^z')
l.append('(x^z)^y')
l.append('y^x^z')
l.append('y^z^x')
l.append('(y^x)^z')
l.append('(y^z)^x')
l.append('z^x^y')
l.append('z^y^x')
l.append('(z^x)^y')
l.append('(z^y)^x')
a = [Decimal(0) for i in range(13)]
a[1] = Decimal(log(x)) * y ** z
a[2] = Decimal(log(x)) * z ** y
a[3] = Decimal(log(x)) * (z * y)
a[4] = a[3]
a[5] = Decimal(log(y)) * x ** z
a[6] = Decimal(log(y)) * z ** x
a[7] = Decimal(log(y)) * (x * z)
a[8] = a[7]
a[9] = Decimal(log(z)) * x ** y
a[10] = Decimal(log(z)) * y ** x
a[11] = Decimal(log(z)) * (x * y)
a[12] = a[11]
mx = Decimal(-10 ** 999)
pos = 0
for i in range(1, 13):
	if a[i] > mx:
		pos = i
		mx = a[i]
print(l[pos])


from decimal import *
(x, y, z) = input().split()
x = Decimal(x)
y = Decimal(y)
z = Decimal(z)
cal1 = lambda x, y, z: y ** z * Decimal.log10(x)
cal2 = lambda x, y, z: y * z * Decimal.log10(x)
(ans, v) = ('x^y^z', cal1(x, y, z))
if cal1(x, z, y) > v:
	(ans, v) = ('x^z^y', cal1(x, z, y))
if cal2(x, y, z) > v:
	(ans, v) = ('(x^y)^z', cal2(x, y, z))
if cal2(x, z, y) > v:
	(ans, v) = ('(x^z)^y', cal2(x, z, y))
if cal1(y, x, z) > v:
	(ans, v) = ('y^x^z', cal1(y, x, z))
if cal1(y, z, x) > v:
	(ans, v) = ('y^z^x', cal1(y, z, x))
if cal2(y, x, z) > v:
	(ans, v) = ('(y^x)^z', cal2(y, x, z))
if cal2(y, z, x) > v:
	(ans, v) = ('(y^z)^x', cal2(y, z, x))
if cal1(z, x, y) > v:
	(ans, v) = ('z^x^y', cal1(z, x, y))
if cal1(z, y, x) > v:
	(ans, v) = ('z^y^x', cal1(z, y, x))
if cal2(z, x, y) > v:
	(ans, v) = ('(z^x)^y', cal2(z, x, y))
if cal2(z, y, x) > v:
	(ans, v) = ('(z^y)^x', cal2(z, y, x))
print(ans)


from decimal import *
(x, y, z) = 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', '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(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(output[-max(a)[1]])


from decimal import Decimal
(x, y, z) = map(Decimal, input().split())
print(sorted(((y ** z * x.ln(), 8, 'x^y^z'), (z ** y * x.ln(), 7, 'x^z^y'), (y * z * x.ln(), 6, '(x^y)^z'), (x ** z * y.ln(), 5, 'y^x^z'), (z ** x * y.ln(), 4, 'y^z^x'), (x * z * y.ln(), 3, '(y^x)^z'), (x ** y * z.ln(), 2, 'z^x^y'), (y ** x * z.ln(), 1, 'z^y^x'), (x * y * z.ln(), 0, '(z^x)^y')))[-1][2])


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 Decimal
(x, y, z) = map(Decimal, input().split())
res = [y ** z * x.ln(), z ** y * x.ln(), y * z * x.ln(), y * z * x.ln(), x ** z * y.ln(), z ** x * y.ln(), x * z * y.ln(), x * z * y.ln(), x ** y * z.ln(), y ** x * z.ln(), x * y * z.ln(), x * y * z.ln()]
arr = ['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(arr[res.index(max(res))])


from math import log

def rk(x, y, z):
	if x <= 1 and y <= 1 and (z <= 1):
		return rk1(x, y, z)
	else:
		return rk2(x, y, z)

def rk1(x, y, z):
	if x == 1:
		return 'x^y^z'
	elif y == 1:
		return 'y^x^z'
	elif z == 1:
		return 'z^x^y'
	lx = log(x)
	ly = log(y)
	lz = log(z)
	l2x = log(-lx)
	l2y = log(-ly)
	l2z = log(-lz)
	a = [(z * ly + l2x, 'x^y^z'), (y * lz + l2x, 'x^z^y'), (ly + lz + l2x, '(x^y)^z'), (z * lx + l2y, 'y^x^z'), (x * lz + l2y, 'y^z^x'), (lz + lx + l2y, '(y^x)^z'), (y * lx + l2z, 'z^x^y'), (x * ly + l2z, 'z^y^x'), (ly + lx + l2z, '(z^x)^y')]
	return min(a, key=lambda t: t[0])[1]

def rk2(x, y, z):
	lx = log(x)
	ly = log(y)
	lz = log(z)
	a = []
	if x > 1:
		l2x = log(lx)
		a += [(z * ly + l2x, 'x^y^z'), (y * lz + l2x, 'x^z^y'), (ly + lz + l2x, '(x^y)^z')]
	if y > 1:
		l2y = log(ly)
		a += [(z * lx + l2y, 'y^x^z'), (x * lz + l2y, 'y^z^x'), (lz + lx + l2y, '(y^x)^z')]
	if z > 1:
		l2z = log(lz)
		a += [(y * lx + l2z, 'z^x^y'), (x * ly + l2z, 'z^y^x'), (ly + lx + l2z, '(z^x)^y')]
	return max(a, key=lambda t: t[0])[1]
(x, y, z) = map(float, input().split())
print(rk(x, y, z))


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 *
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-06
for i in range(0, 12):
	if f[i] > f[x] + Decimal(eps):
		x = i
print(ans[x])


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))


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 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 Decimal
(x, y, z) = map(Decimal, input().split())
fs = [lambda x, y, z: y ** z * x.ln(), lambda x, y, z: z ** y * x.ln(), lambda x, y, z: y * z * x.ln(), lambda x, y, z: y * z * x.ln(), lambda x, y, z: x ** z * y.ln(), lambda x, y, z: z ** x * y.ln(), lambda x, y, z: x * z * y.ln(), lambda x, y, z: x * z * y.ln(), lambda x, y, z: x ** y * z.ln(), lambda x, y, z: y ** x * z.ln(), lambda x, y, z: x * y * z.ln(), lambda x, y, z: x * y * z.ln()]
arr = ['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']
res = [f(x, y, z) for f in fs]
print(arr[res.index(max(res))])


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 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 *
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 decimal import *
from math import log

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

def __starting_point():
	(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), (x ** z * d_log(y), 4), (z ** x * d_log(y), 5), (z * x * d_log(y), 6), (x ** y * d_log(z), 8), (y ** x * d_log(z), 9), (y * x * d_log(z), 10)]
	exps.sort(key=lambda e: (-e[0], e[1]))
	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()


from decimal import Decimal
import math
(x, y, z) = map(Decimal, input().split())
arr = []
for i in range(10):
	arr.append(0)
output = ['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[0] = x.ln() * y ** z
arr[1] = x.ln() * z ** y
arr[2] = x.ln() * y * z
arr[3] = y.ln() * x ** z
arr[4] = y.ln() * z ** x
arr[5] = y.ln() * x * z
arr[6] = z.ln() * x ** y
arr[7] = z.ln() * y ** x
arr[8] = z.ln() * x * y
maxi = 0
for i in range(1, 9):
	d = arr[i] - arr[maxi]
	if d > 1 / 1000000000:
		maxi = i
print(output[maxi])


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) = 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]])


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) = 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]))
	ans = anss[-1][1]
print(ans)


import math
inp = input().split()
x = float(inp[0])
y = float(inp[1])
z = float(inp[2])
arr = [[x, y, z], [x, z, y], [x, y * z, 1], [x, z * y, 1], [y, x, z], [y, z, x], [y, x * z, 1], [y, z * x, 1], [z, x, y], [z, y, x], [z, x * y, 1], [z, y * x, 1]]
idd = 0

def comp(a, b):
	if len(a) == 3 and len(b) == 3:
		an1 = math.log(a[0])
		an2 = math.log(b[0])
		if an1 < 0 and an2 >= 0:
			return False
		elif an1 >= 0 and an2 < 0:
			return True
		swapped = False
		if an1 < 0 and an2 < 0:
			an1 = -an1
			an2 = -an2
			swapped = True
		if a[0] == 0 and b[0] == 0:
			return False
		if a[0] == 1:
			return math.log(b[0]) < 0
		if b[0] == 1:
			return math.log(a[0]) > 0
		ans1 = a[2] * math.log(a[1]) + math.log(an1)
		ans2 = b[2] * math.log(b[1]) + math.log(an2)
		if swapped:
			return ans1 < ans2
		else:
			return ans1 > ans2
for i in range(len(arr)):
	if comp(arr[i], arr[idd]):
		idd = i
if idd == 0:
	print('x^y^z')
elif idd == 1:
	print('x^z^y')
elif idd == 2:
	print('(x^y)^z')
elif idd == 3:
	print('(x^z)^y')
elif idd == 4:
	print('y^x^z')
elif idd == 5:
	print('y^z^x')
elif idd == 6:
	print('(y^x)^z')
elif idd == 7:
	print('(y^z)^x')
elif idd == 8:
	print('z^x^y')
elif idd == 9:
	print('z^y^x')
elif idd == 10:
	print('(z^x)^y')
elif idd == 11:
	print('(z^y)^x')


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 decimal import *
getcontext().prec = 700
(x, y, z) = map(Decimal, input().split())
a = []
a.append((y ** z * x.ln(), -1, 'x^y^z'))
a.append((z ** y * x.ln(), -2, 'x^z^y'))
a.append((y * z * x.ln(), -3, '(x^y)^z'))
a.append((x ** z * y.ln(), -5, 'y^x^z'))
a.append((z ** x * y.ln(), -6, 'y^z^x'))
a.append((x * z * y.ln(), -7, '(y^x)^z'))
a.append((x ** y * z.ln(), -9, 'z^x^y'))
a.append((y ** x * z.ln(), -10, 'z^y^x'))
a.append((x * y * z.ln(), -11, '(z^x)^y'))
print(max(a)[2])


from decimal import *
(x, y, z) = map(Decimal, input().split())
A = []
A.append((y ** z * x.ln(), -1, 'x^y^z'))
A.append((z ** y * x.ln(), -2, 'x^z^y'))
A.append((y * z * x.ln(), -3, '(x^y)^z'))
A.append((x ** z * y.ln(), -5, 'y^x^z'))
A.append((z ** x * y.ln(), -6, 'y^z^x'))
A.append((x * z * y.ln(), -7, '(y^x)^z'))
A.append((x ** y * z.ln(), -9, 'z^x^y'))
A.append((y ** x * z.ln(), -10, 'z^y^x'))
A.append((x * y * z.ln(), -11, '(z^x)^y'))
print(max(A)[2])


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) = 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]])


import decimal
decimal.getcontext().prec = 300
(x, y, z) = input().split()
eps = decimal.Decimal(1)
eps /= 10 ** 200

def tr(x):
	(a, b) = x.split('.')
	a = int(a)
	b = int(b)
	a = decimal.Decimal(a)
	b = decimal.Decimal(b)
	b /= 10
	return a + b
x = tr(x)
y = tr(y)
z = tr(z)

def f(x, y, z):
	return y ** z * x.ln()

def g(x, y, z):
	return y * z * x.ln()

def chf(ans, x, y, z):
	if abs(ans) < eps:
		return f(x, y, z) > -eps
	return abs(ans - f(x, y, z)) / abs(ans) < eps

def chg(ans, x, y, z):
	if abs(ans) < eps:
		return g(x, y, z) > -eps
	return abs(ans - g(x, y, z)) / abs(ans) < eps
ans = decimal.Decimal(0)
ans = max(f(x, y, z), f(x, z, y), f(y, x, z), f(y, z, x), f(z, x, y), f(z, y, x))
ans = max(ans, g(x, y, z), g(x, z, y), g(y, x, z), g(y, z, x), g(z, x, y), g(z, y, x))
if chf(ans, x, y, z):
	print('x^y^z')
elif chf(ans, x, z, y):
	print('x^z^y')
elif chf(ans, y, x, z):
	print('y^x^z')
elif chf(ans, y, z, x):
	print('y^z^x')
elif chf(ans, z, x, y):
	print('z^x^y')
elif chf(ans, z, y, x):
	print('z^y^x')
elif chg(ans, x, y, z):
	print('(x^y)^z')
elif chg(ans, x, z, y):
	print('(x^z)^y')
elif chg(ans, y, x, z):
	print('(y^x)^z')
elif chg(ans, y, z, x):
	print('(y^z)^x')
elif chg(ans, z, x, y):
	print('(z^x)^y')
elif chg(ans, z, y, x):
	print('(z^y)^x')


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]
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']
i = 0
for j in range(12):
	if abs(l[j] - m) < Decimal('.' + '0' * 100 + '1'):
		i = j
		break
print(s[i])


import math
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) = 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]
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
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
ar = list(map(float, input().split()))
mn = -float('inf')
mns = ''

def xyz(x, y, z, op):
	if op == 1:
		return (x ** y ** z, 'x^y^z')
	elif op == 2:
		return (x ** z ** y, 'x^z^y')
	elif op == 5:
		return (y ** x ** z, 'y^x^z')
	elif op == 6:
		return (y ** z ** x, 'y^z^x')
	elif op == 9:
		return (z ** x ** y, 'z^x^y')
	elif op == 10:
		return (z ** y ** x, 'z^y^x')
	elif op == 3:
		return ((x ** y) ** z, '(x^y)^z')
	elif op == 4:
		return ((x ** z) ** y, '(x^z)^y')
	elif op == 7:
		return ((y ** x) ** z, '(y^x)^z')
	elif op == 8:
		return ((y ** z) ** x, '(y^z)^x')
	elif op == 11:
		return ((z ** x) ** y, '(z^x)^y')
	elif op == 12:
		return ((z ** y) ** x, '(z^y)^x')

def xyz2(x, y, z, op):
	if op == 1:
		try:
			vl = math.log2(math.log2(x)) + math.log2(y) * z
		except:
			vl = -float('inf')
		return (vl, 'x^y^z')
	elif op == 2:
		try:
			vl = math.log2(math.log2(x)) + math.log2(z) * y
		except:
			vl = -float('inf')
		return (vl, 'x^z^y')
	elif op == 5:
		try:
			vl = math.log2(math.log2(y)) + math.log2(x) * z
		except:
			vl = -float('inf')
		return (vl, 'y^x^z')
	elif op == 6:
		try:
			vl = math.log2(math.log2(y)) + math.log2(z) * x
		except:
			vl = -float('inf')
		return (vl, 'y^z^x')
	elif op == 9:
		try:
			vl = math.log2(math.log2(z)) + math.log2(x) * y
		except:
			vl = -float('inf')
		return (vl, 'z^x^y')
	elif op == 10:
		try:
			vl = math.log2(math.log2(z)) + math.log2(y) * x
		except:
			vl = -float('inf')
		return (vl, 'z^y^x')
	elif op == 3:
		try:
			vl = math.log2(math.log2(x)) + math.log2(y) + math.log2(z)
		except:
			vl = -float('inf')
		return (vl, '(x^y)^z')
	elif op == 4:
		try:
			vl = math.log2(math.log2(x)) + math.log2(z) + math.log2(y)
		except:
			vl = -float('inf')
		return (vl, '(x^z)^y')
	elif op == 7:
		try:
			vl = math.log2(math.log2(y)) + math.log2(x) + math.log2(z)
		except:
			vl = -float('inf')
		return (vl, '(y^x)^z')
	elif op == 8:
		try:
			vl = math.log2(math.log2(y)) + math.log2(x) + math.log2(z)
		except:
			vl = -float('inf')
		return (vl, '(y^z)^x')
	elif op == 11:
		try:
			vl = math.log2(math.log2(z)) + math.log2(x) + math.log2(y)
		except:
			vl = -float('inf')
		return (vl, '(z^x)^y')
	elif op == 12:
		try:
			vl = math.log2(math.log2(z)) + math.log2(x) + math.log2(y)
		except:
			vl = -float('inf')
		return (vl, '(z^y)^x')
E = [[0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0]]
if max(ar) < 4.1:
	for i in range(1, 13):
		a = xyz(ar[0], ar[1], ar[2], i)
		if a[0] - 1e-07 > mn:
			mn = a[0]
			mns = a[1]
else:
	for i in range(1, 13):
		a = xyz2(ar[0], ar[1], ar[2], i)
		if a[0] - 1e-07 > mn:
			mn = a[0]
			mns = a[1]
print(mns)


from math import log
from decimal import Decimal
asd = ['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']
ans = []
(x, y, z) = map(Decimal, input().split())

def pow2(a, b):
	return a ** b
ans.append(x.ln() * pow2(y, z))
ans.append(x.ln() * pow2(z, y))
ans.append(x.ln() * y * z)
ans.append(x.ln() * y * z)
ans.append(y.ln() * pow2(x, z))
ans.append(y.ln() * pow2(z, x))
ans.append(y.ln() * x * z)
ans.append(y.ln() * x * z)
ans.append(z.ln() * pow2(x, y))
ans.append(z.ln() * pow2(y, x))
ans.append(z.ln() * y * x)
ans.append(z.ln() * y * x)
anss = -10000000000000000000000000000
for i in range(12):
	if ans[i] > anss:
		anss = ans[i]
for i in range(12):
	if ans[i] == anss:
		print(asd[i])
		exit()


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 *
(x, y, z) = map(Decimal, input().split())
print(max((y ** z * x.ln(), 9, 'x^y^z'), (z ** y * x.ln(), 8, 'x^z^y'), (y * z * x.ln(), 7, '(x^y)^z'), (x ** z * y.ln(), 6, 'y^x^z'), (z ** x * y.ln(), 5, 'y^z^x'), (z * x * y.ln(), 4, '(y^x)^z'), (x ** y * z.ln(), 3, 'z^x^y'), (y ** x * z.ln(), 2, 'z^y^x'), (y * x * z.ln(), 1, '(z^x)^y'))[2])


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

def solver1(x, y, z):
	max_num = y ** z * log(x)
	ans = 'x^y^z'
	num = z ** y * log(x)
	if max_num < num:
		max_num = num
		ans = 'x^z^y'
	num = y * z * log(x)
	if max_num < num:
		max_num = num
		ans = '(x^y)^z'
	num = x ** z * log(y)
	if max_num < num:
		max_num = num
		ans = 'y^x^z'
	num = z ** x * log(y)
	if max_num < num:
		max_num = num
		ans = 'y^z^x'
	num = x * z * log(y)
	if max_num < num:
		max_num = num
		ans = '(y^x)^z'
	num = x ** y * log(z)
	if max_num < num:
		max_num = num
		ans = 'z^x^y'
	num = y ** x * log(z)
	if max_num < num:
		max_num = num
		ans = 'z^y^x'
	num = x * y * log(z)
	if max_num < num:
		max_num = num
		ans = '(z^x)^y'
	return ans

def solver2(x, y, z):
	max_num = z * log(y) + log(log(x))
	ans = 'x^y^z'
	num = y * log(z) + log(log(x))
	if max_num < num:
		max_num = num
		ans = 'x^z^y'
	num = log(y) + log(z) + log(log(x))
	if max_num < num:
		max_num = num
		ans = '(x^y)^z'
	num = z * log(x) + log(log(y))
	if max_num < num:
		max_num = num
		ans = 'y^x^z'
	num = x * log(z) + log(log(y))
	if max_num < num:
		max_num = num
		ans = 'y^z^x'
	num = log(x) + log(z) + log(log(y))
	if max_num < num:
		max_num = num
		ans = '(y^x)^z'
	num = y * log(x) + log(log(z))
	if max_num < num:
		max_num = num
		ans = 'z^x^y'
	num = x * log(y) + log(log(z))
	if max_num < num:
		max_num = num
		ans = 'z^y^x'
	num = log(x) + log(y) + log(log(z))
	if max_num < num:
		max_num = num
		ans = '(z^x)^y'
	return ans

def solverX(x, y, z):
	max_num = z * log(x) + log(log(y))
	ans = 'y^x^z'
	num = x * log(z) + log(log(y))
	if max_num < num:
		max_num = num
		ans = 'y^z^x'
	num = log(x) + log(z) + log(log(y))
	if max_num < num:
		max_num = num
		ans = '(y^x)^z'
	num = y * log(x) + log(log(z))
	if max_num < num:
		max_num = num
		ans = 'z^x^y'
	num = x * log(y) + log(log(z))
	if max_num < num:
		max_num = num
		ans = 'z^y^x'
	num = log(x) + log(y) + log(log(z))
	if max_num < num:
		max_num = num
		ans = '(z^x)^y'
	return ans

def solverY(x, y, z):
	max_num = z * log(y) + log(log(x))
	ans = 'x^y^z'
	num = y * log(z) + log(log(x))
	if max_num < num:
		max_num = num
		ans = 'x^z^y'
	num = log(y) + log(z) + log(log(x))
	if max_num < num:
		max_num = num
		ans = '(x^y)^z'
	num = y * log(x) + log(log(z))
	if max_num < num:
		max_num = num
		ans = 'z^x^y'
	num = x * log(y) + log(log(z))
	if max_num < num:
		max_num = num
		ans = 'z^y^x'
	num = log(x) + log(y) + log(log(z))
	if max_num < num:
		max_num = num
		ans = '(z^x)^y'
	return ans

def solverZ(x, y, z):
	max_num = z * log(y) + log(log(x))
	ans = 'x^y^z'
	num = y * log(z) + log(log(x))
	if max_num < num:
		max_num = num
		ans = 'x^z^y'
	num = log(y) + log(z) + log(log(x))
	if max_num < num:
		max_num = num
		ans = '(x^y)^z'
	num = z * log(x) + log(log(y))
	if max_num < num:
		max_num = num
		ans = 'y^x^z'
	num = x * log(z) + log(log(y))
	if max_num < num:
		max_num = num
		ans = 'y^z^x'
	num = log(x) + log(z) + log(log(y))
	if max_num < num:
		max_num = num
		ans = '(y^x)^z'
	return ans
(x, y, z) = map(float, input().split())
if x <= 1 and y <= 1 and (z <= 1):
	ans = solver1(x, y, z)
elif x > 1 and y > 1 and (z > 1):
	ans = solver2(x, y, z)
elif x > 1 and y <= 1 and (z <= 1):
	ans = solver1(x, y, z)
elif x <= 1 and y > 1 and (z <= 1):
	ans = solver1(x, y, z)
elif x <= 1 and y <= 1 and (z > 1):
	ans = solver1(x, y, z)
elif x > 1 and y > 1 and (z <= 1):
	ans = solverZ(x, y, z)
elif x > 1 and y <= 1 and (z > 1):
	ans = solverY(x, y, z)
elif x <= 1 and y > 1 and (z > 1):
	ans = solverX(x, y, z)
print(ans)


from decimal import *
(x, y, z) = map(Decimal, input().split())
l = [(y ** z * x.ln(), -1, 'x^y^z')]
l += [(z ** y * x.ln(), -2, 'x^z^y')]
l += [(y * z * x.ln(), -3, '(x^y)^z')]
l += [(z * y * x.ln(), -4, '(x^z)^y')]
l += [(x ** z * y.ln(), -5, 'y^x^z')]
l += [(z ** x * y.ln(), -6, 'y^z^x')]
l += [(z * x * y.ln(), -7, '(y^x)^z')]
l += [(x * z * y.ln(), -8, '(y^z)^x')]
l += [(x ** y * z.ln(), -9, 'z^x^y')]
l += [(y ** x * z.ln(), -10, 'z^y^x')]
l += [(y * x * z.ln(), -11, '(z^x)^y')]
l += [(x * y * z.ln(), -12, '(z^y)^x')]
print(max(l)[2])