AtCoder Beginner Contest 079 - Train Ticket

Sitting in a station waiting room, Joisino is gazing at her train ticket.
The ticket is numbered with four digits A, B, C and D in this order, each between 0 and 9 (inclusive).
In the formula A op1 B op2 C op3 D = 7, replace each of the symbols op1, op2 and op3 with + or - so that the formula holds.
The given input guarantees that there is a solution. If there are multiple solutions, any of them will be accepted.

-----Constraints-----
 - 0≤A,B,C,D≤9
 - All input values are integers.
 - It is guaranteed that there is a solution.

-----Input-----
Input is given from Standard Input in the following format:
ABCD

-----Output-----
Print the formula you made, including the part =7.
Use the signs + and -.
Do not print a space between a digit and a sign.

-----Sample Input-----
1222

-----Sample Output-----
1+2+2+2=7

This is the only valid solution.

Difficulty: EASY

Starter code:

Solutions:
n = input()
N = [int(i) for i in n]
for i in range(8):
	n = format(i, '03b')
	ans = N[0]
	msg = str(N[0])
	for j in range(3):
		if n[j] == '0':
			ans += N[j + 1]
			msg += '+' + str(N[j + 1])
		else:
			ans -= N[j + 1]
			msg += '-' + str(N[j + 1])
	if ans == 7:
		print(msg + '=7')
		break


(A, B, C, D) = input()
op = '+-'
for a in op:
	for b in op:
		for c in op:
			_ = A + a + B + b + C + c + D
			if eval(_) == 7:
				print(_ + '=7')
				exit()


s = input()
for a in ['+', '-']:
	for b in ['+', '-']:
		for c in ['+', '-']:
			str = s[0] + a + s[1] + b + s[2] + c + s[3]
			if eval(str) == 7:
				ans = str
print(ans + '=7')


A = input()
B = [''.join(sum(list(map(list, zip(A, ''.join(('+-'[int(s)] for s in '{:03b}'.format(i))) + '='))), []))[:-1] for i in range(8)]
for b in B:
	if eval(b) == 7:
		print(b + '=7')
		break


a = list(input())
for i in range(8):
	t = ''.join([a[0]] + ['+-'[i >> k & 1] + v for (k, v) in enumerate(a[1:])])
	if eval(t) == 7:
		print(t + '=7')
		break


n = input()
for i in '+-':
	for j in '+-':
		for k in '+-':
			a = n[0] + i + n[1] + j + n[2] + k + n[3]
			if eval(a) == 7:
				print(a + '=7')
				exit()


s = input()
ans = ''
for i in range(8):
	l = ''
	for j in range(4):
		l += s[j]
		if j != 3:
			l += '+' if i >> j & 1 else '-'
	if eval(l) == 7:
		ans = l
		break
print(l + '=7')


ABCD = input()
for i in range(1 << 3):
	t = ABCD[0]
	for j in range(3):
		t += '+-'[(i >> j) % 2]
		t += ABCD[j + 1]
	if eval(t) == 7:
		print(t + '=7')
		exit()


import itertools
l = list(input())
for i in itertools.product('+-', repeat=3):
	s = l[0] + i[0] + l[1] + i[1] + l[2] + i[2] + l[3]
	m = eval(s)
	if m == 7:
		print(s + '=7')
		break


import sys
import itertools
(a, b, c, d) = [i for i in input()]
op = ['+', '-']
for i in itertools.product(op, repeat=3):
	ev = a + i[0] + b + i[1] + c + i[2] + d
	if eval(ev) == 7:
		print(ev + '=7')
		sys.exit()


from itertools import product
(A, B, C, D) = list(input())
for x in product(('+', '-'), repeat=3):
	if eval(A + x[0] + B + x[1] + C + x[2] + D) == 7:
		print(A + x[0] + B + x[1] + C + x[2] + D + '=7')
		break


from itertools import combinations
s = input()
ans = ['-', '-', '-']
for i in range(4):
	for comb in combinations(range(3), i):
		temp = int(s[0])
		for j in range(3):
			if j in comb:
				temp += int(s[j + 1])
			else:
				temp -= int(s[j + 1])
		if temp == 7:
			for j in comb:
				ans[j] = '+'
			break
print('{a}{op1}{b}{op2}{c}{op3}{d}=7'.format(a=s[0], op1=ans[0], b=s[1], op2=ans[1], c=s[2], op3=ans[2], d=s[3]))


import itertools
(A, B, C, D) = list(input())
op = ['+', '-']
for (op1, op2, op3) in itertools.product(op, op, op):
	x = A + op1 + B + op2 + C + op3 + D
	if eval(x) == 7:
		print(x + '=7')
		break


(a, b, c, d) = input()
lst_1 = []
lst_2 = ['+', '-']
for i in lst_2:
	for j in lst_2:
		for k in lst_2:
			lst_1.append(a + i + b + j + c + k + d)
for l in lst_1:
	if eval(l) == 7:
		print(l + '=7')
		break


N = list(str(input()))
F = [N[0] + '+-'[i % 2] + N[1] + '+-'[i // 2 % 2] + N[2] + '+-'[i // 4 % 2] + N[3] for i in range(8)]
for f in F:
	if eval(f) == 7:
		print(f + '=7')
		break
	else:
		continue


A = input()
for i in range(8):
	B = format(i, '03b').replace('0', '-').replace('1', '+')
	ans = ''.join([a + b for (b, a) in zip(B, A)]) + A[-1]
	if eval(ans) == 7:
		print(ans + '=7')
		exit()


import itertools
(a, b, c, d) = input()
op = ['+', '-']
for (op1, op2, op3) in itertools.product(op, repeat=3):
	s = a + op1 + b + op2 + c + op3 + d
	if eval(s) == 7:
		print(s + '=7')
		break


import itertools
n = input()
op = list(itertools.product(['+', '-'], repeat=3))
l = list(n)
for i in op:
	tmp = n[0] + i[0] + n[1] + i[1] + n[2] + i[2] + n[3]
	if eval(tmp) == 7:
		print(tmp + '=7')
		break


(a, b, c, d) = input()
e = '+-'
for i in e:
	for j in e:
		for k in e:
			s = a + i + b + j + c + k + d
			if eval(s) == 7:
				print(s + '=7')
				exit()


import os
import sys

def main():
	L = input()
	if int(L[0]) + int(L[1]) + int(L[2]) + int(L[3]) == 7:
		print('{}+{}+{}+{}=7'.format(L[0], L[1], L[2], L[3]))
	elif int(L[0]) + int(L[1]) + int(L[2]) - int(L[3]) == 7:
		print('{}+{}+{}-{}=7'.format(L[0], L[1], L[2], L[3]))
	elif int(L[0]) + int(L[1]) - int(L[2]) + int(L[3]) == 7:
		print('{}+{}-{}+{}=7'.format(L[0], L[1], L[2], L[3]))
	elif int(L[0]) - int(L[1]) + int(L[2]) + int(L[3]) == 7:
		print('{}-{}+{}+{}=7'.format(L[0], L[1], L[2], L[3]))
	elif int(L[0]) + int(L[1]) - int(L[2]) - int(L[3]) == 7:
		print('{}+{}-{}-{}=7'.format(L[0], L[1], L[2], L[3]))
	elif int(L[0]) - int(L[1]) + int(L[2]) - int(L[3]) == 7:
		print('{}-{}+{}-{}=7'.format(L[0], L[1], L[2], L[3]))
	elif int(L[0]) - int(L[1]) - int(L[2]) + int(L[3]) == 7:
		print('{}-{}-{}+{}=7'.format(L[0], L[1], L[2], L[3]))
	elif int(L[0]) - int(L[1]) - int(L[2]) - int(L[3]) == 7:
		print('{}-{}-{}-{}=7'.format(L[0], L[1], L[2], L[3]))

def __starting_point():
	main()
__starting_point()


a = input()
for i in range(1 << 3):
	s = a[0]
	for j in range(3):
		if i >> j & 1:
			s += '+'
		else:
			s += '-'
		s += a[j + 1]
	if eval(s) == 7:
		ans = s + '=7'
print(ans)


N = input()
for i in range(1 << 3):
	s = N[0]
	for j in range(3):
		s += '+-'[i >> j & 1] + N[j + 1]
	if eval(s) == 7:
		print(s + '=7')
		break


import itertools
(a, b, c, d) = list(input())
for ops in itertools.product(['+', '-'], repeat=3):
	eq = a + ops[0] + b + ops[1] + c + ops[2] + d
	x = eval(eq)
	if x == 7:
		break
answer = eq + '=7'
print(answer)


(A, B, C, D) = input()
op = ['+', '-']
for op1 in op:
	for op2 in op:
		for op3 in op:
			s = A + op1 + B + op2 + C + op3 + D
			if eval(s) == 7:
				print(s + '=7')
				exit()


S = input()
for i in range(8):
	s = S[0] + ''.join(('+-'[i >> j & 1] + c for (j, c) in enumerate(S[1:])))
	if eval(s) == 7:
		print(s + '=7')
		break


(a, b, c, d) = input()
s = '+-'
for p in s:
	for q in s:
		for r in s:
			f = a + p + b + q + c + r + d
			if eval(f) == 7:
				print(f + '=7')
				exit()


def kumiawase(S, op, i=0, x=0):
	if i == 4:
		if x == 7:
			print(op + '=7')
			return True
		else:
			return False
	if kumiawase(S, op + '+' + S[i], i + 1, x + int(S[i])):
		return True
	if kumiawase(S, op + '-' + S[i], i + 1, x - int(S[i])):
		return True
S = input()
kumiawase(S, S[0], 1, int(S[0]))


(a, b, c, d) = input()
o = '+-- -'
for i in range(8):
	s = a + o[i & 1] + b + o[i & 2] + c + o[i & 4] + d
	if eval(s) == 7:
		print(s + '=7')
		break


s = input()
for i in range(2 ** 3):
	b = bin(i)[2:].zfill(3)
	a = s[0]
	for i in range(3):
		a += ('+' if b[i] == '0' else '-') + s[i + 1]
	if eval(a) == 7:
		print(a + '=7')
		exit()


s = input()
for i in range(2 ** 3):
	f = s[0]
	for j in range(3):
		if i >> j & 1:
			f += '+'
		else:
			f += '-'
		f += s[j + 1]
	ans = eval(f)
	if ans == 7:
		print(f + '=7')
		break


from itertools import product
(A, B, C, D) = list(input().strip())
for x in product(('+', '-'), repeat=3):
	(a1, a2, a3) = x
	if eval(A + a1 + B + a2 + C + a3 + D) == 7:
		print(A + a1 + B + a2 + C + a3 + D + '=7')
		break


import itertools
(a, b, c, d) = list(input())
for i in itertools.product(['+', '-'], repeat=3):
	x = a + i[0] + b + i[1] + c + i[2] + d
	if eval(x) == 7:
		break
print(x + '=7')


from itertools import product
(A, B, C, D) = list(input())
for (x, y, z) in product(['+', '-'], repeat=3):
	eqn = A + x + B + y + C + z + D
	if eval(eqn) == 7:
		print(f'{eqn}=7')
		break


import itertools
s = input()
for p in itertools.product('+-', repeat=3):
	formula = s[0] + p[0] + s[1] + p[1] + s[2] + p[2] + s[3]
	if eval(formula) == 7:
		print(formula + '=7')
		exit()


n = str(input())
a = int(n[0])
b = int(n[1])
c = int(n[2])
d = int(n[3])
if a + b + c + d == 7:
	ans = str(a) + '+' + str(b) + '+' + str(c) + '+' + str(d)
elif a + b + c - d == 7:
	ans = str(a) + '+' + str(b) + '+' + str(c) + '-' + str(d)
elif a + b - c + d == 7:
	ans = str(a) + '+' + str(b) + '-' + str(c) + '+' + str(d)
elif a + b - c - d == 7:
	ans = str(a) + '+' + str(b) + '-' + str(c) + '-' + str(d)
elif a - b + c + d == 7:
	ans = str(a) + '-' + str(b) + '+' + str(c) + '+' + str(d)
elif a - b + c - d == 7:
	ans = str(a) + '-' + str(b) + '+' + str(c) + '-' + str(d)
elif a - b - c + d == 7:
	ans = str(a) + '-' + str(b) + '-' + str(c) + '+' + str(d)
elif a - b - c - d == 7:
	ans = str(a) + '-' + str(b) + '-' + str(c) + '-' + str(d)
print(ans + '=7')


(a, b, c, d) = map(int, input())
if a + b - c + d == 7:
	print('%d+%d-%d+%d=7' % (a, b, c, d))
	return
elif a + b - c - d == 7:
	print('%d+%d-%d-%d=7' % (a, b, c, d))
	return
elif a - b - c + d == 7:
	print('%d-%d-%d+%d=7' % (a, b, c, d))
	return
elif a - b - c - d == 7:
	print('%d-%d-%d-%d=7' % (a, b, c, d))
	return
elif a + b + c + d == 7:
	print('%d+%d+%d+%d=7' % (a, b, c, d))
	return
elif a + b + c - d == 7:
	print('%d+%d+%d-%d=7' % (a, b, c, d))
	return
elif a - b + c + d == 7:
	print('%d-%d+%d+%d=7' % (a, b, c, d))
	return
elif a - b + c - d == 7:
	print('%d-%d+%d-%d=7' % (a, b, c, d))
	return


import itertools
ABCD = input()
for op in itertools.product(['+', '-'], repeat=3):
	s = ABCD[0] + op[0] + ABCD[1] + op[1] + ABCD[2] + op[2] + ABCD[3]
	if eval(s) == 7:
		print(s + '=7')
		exit()


S0 = input()
for i in range(1 << 3):
	S = S0
	for j in range(3):
		if i >> j & 1 == 1:
			S = S[:3 - j] + '+' + S[3 - j:]
		else:
			S = S[:3 - j] + '-' + S[3 - j:]
	if eval(S) == 7:
		print(S + '=7')
		exit()


A = input()
N = len(A)
for i in range(2 ** (N - 1)):
	s = A[0]
	for j in range(N - 1):
		if i >> j & 1:
			s += '+'
		else:
			s += '-'
		s += A[j + 1]
	if eval(s) == 7:
		print(s + '=7')
		break


(a, b, c, d) = open(0).read().rstrip()
from itertools import product
for (o, p, q) in product(['-', '+'], repeat=3):
	state = a + o + b + p + c + q + d
	if eval(state) == 7:
		print(state + '=7')
		break


n = input()
l = [1, -1]
l1 = [0, '+', '-']
s = ''
for i in l:
	for j in l:
		for k in l:
			if int(n[0]) + i * int(n[1]) + j * int(n[2]) + k * int(n[3]) == 7:
				s = n[0] + l1[i] + n[1] + l1[j] + n[2] + l1[k] + n[3] + '=7'
print(s)


a = list(input())
l = ['+', '-']
for p in l:
	for q in l:
		for r in l:
			x = a[0] + p + a[1] + q + a[2] + r + a[3]
			if eval(x) == 7:
				print(x + '=7')
				exit()


from itertools import product
S = input()
for x in product(('+', '-'), repeat=3):
	if eval(S[0] + x[0] + S[1] + x[1] + S[2] + x[2] + S[3]) == 7:
		print(S[0] + x[0] + S[1] + x[1] + S[2] + x[2] + S[3] + '=7')
		break


(a, *l) = input()
for i in range(8):
	f = a
	for j in range(3):
		f += '-+'[i >> j & 1] + l[j]
	if eval(f) == 7:
		print(f + '=7')
		exit()


(a, b, c, d) = input()
S = '+-'
for i in S:
	for j in S:
		for k in S:
			left = a + i + b + j + c + k + d
			if eval(left) == 7:
				print(left + '=7')
				return


n = list(input())
op = '+----'
for i in range(8):
	s = n[0] + op[i & 4] + n[1] + op[i & 2] + n[2] + op[i & 1] + n[3]
	if eval(s) == 7:
		print(s + '=7')
		break


S = input()
for i in range(8):
	t = ''
	for j in range(3):
		t += S[j] + ['+', '-'][not 1 & i >> j]
	t += S[-1]
	if 7 == eval(t):
		print(t + '=7')
		break


o = ['+', '-']
(a, b, c, d) = list(input())
for i in o:
	for j in o:
		for k in o:
			t = a + i + b + j + c + k + d
			if eval(t) == 7:
				print(t + '=7')
				exit()


(A, B, C, D) = list(input())
import itertools
for ops in itertools.product(['+', '-'], repeat=3):
	eq = A + ops[0] + B + ops[1] + C + ops[2] + D
	x = eval(eq)
	if x == 7:
		break
answer = eq + '=7'
print(answer)


s = input()
ans1 = s[0]

def solve(i, tmp, ans):
	nonlocal ans1
	if i == 3:
		if tmp == 7:
			ans1 = ans
			return True
		else:
			return False
	if solve(i + 1, tmp + int(s[i + 1]), ans + '+' + s[i + 1]):
		return True
	if solve(i + 1, tmp - int(s[i + 1]), ans + '-' + s[i + 1]):
		return True
if solve(0, int(s[0]), ans1):
	print(ans1 + '=7')


s = input()
for i1 in ['+', '-']:
	for i2 in ['+', '-']:
		for i3 in ['+', '-']:
			text = s[0] + i1 + s[1] + i2 + s[2] + i3 + s[3]
			if eval(text) == 7:
				print(text + '=7')
				exit()


import itertools
a = list(input())
for v in itertools.product(['+', '-'], repeat=3):
	x = a[0] + v[0] + a[1] + v[1] + a[2] + v[2] + a[3]
	if eval(x) == 7:
		break
print(x + '=7')


from itertools import *
(A, B, C, D) = input()
for (i, j, k) in product(['+', '-'], repeat=3):
	s = A + i + B + j + C + k + D
	if eval(s) == 7:
		print(s + '=7')
		break


(a, b, c, d) = list(input())
en = ['+', '-']
for x in en:
	for y in en:
		for z in en:
			s = a + x + b + y + c + z + d
			if eval(s) == 7:
				print(s + '=7')
				exit()


a = input()
for op1 in ['+', '-']:
	for op2 in ['+', '-']:
		for op3 in ['+', '-']:
			if eval(a[0] + op1 + a[1] + op2 + a[2] + op3 + a[3]) == 7:
				ans = a[0] + op1 + a[1] + op2 + a[2] + op3 + a[3] + '=7'
print(ans)


s = input()
s8 = []

def cal(p, n):
	if n == 0:
		s8.append(p)
	else:
		cal(p[:n] + '+' + p[n:], n - 1)
		cal(p[:n] + '-' + p[n:], n - 1)
cal(s, len(s) - 1)
for ss in s8:
	if eval(ss) == 7:
		print(ss + '=7')
		exit()


a = input()
for i in range(2 ** (len(a) - 1)):
	tmp = a[0] + ''.join(['+-'[i >> j & 1] + k for (j, k) in enumerate(a[1:])])
	if eval(tmp) == 7:
		print(tmp + '=7')
		break


S = input()
for i in range(1 << 3):
	tmp = S[0]
	for j in range(3):
		if i >> j & 1 == 1:
			tmp += '+'
		else:
			tmp += '-'
		tmp += S[j + 1]
	if eval(tmp) == 7:
		break
print(tmp + '=7')


def dfs(i, f, ans):
	if i < 3:
		dfs(i + 1, f + '+' + s[i + 1], ans + int(s[i + 1]))
		dfs(i + 1, f + '-' + s[i + 1], ans - int(s[i + 1]))
	elif ans == 7:
		print(f + '=7')
		exit()
s = input()
dfs(0, s[0], int(s[0]))


from itertools import product
s = input()
for p in product('+-', repeat=3):
	r = s[0]
	for i in range(3):
		r += p[i] + s[i + 1]
	if eval(r) == 7:
		print(r + '=7')
		break


s = input()
for i in range(2 ** 3):
	t = s[0]
	for j in range(3):
		if i % 2:
			t += '+'
		else:
			t += '-'
		i //= 2
		t += s[j + 1]
	if eval(t + '==7'):
		print(t + '=7')
		exit()


ABCD = input()
f = ''
for bit in range(1 << 3):
	f = ABCD[0]
	for i in range(3):
		if bit & 1 << i:
			f += '+'
		else:
			f += '-'
		f += ABCD[i + 1]
	if eval(f) == 7:
		print(f + '=7')
		exit()


from itertools import product
s = input()
s2 = '{}'.join(s)
opss = product('+-', repeat=3)
lhss = (s2.format(*ops) for ops in opss)
eqs = (lhs + '=7' for lhs in lhss if eval(lhs) == 7)
print(next(eqs))


import itertools
S = input()
TT = itertools.product(['+', '-'], repeat=3)
for T in TT:
	A = S[0] + T[0] + S[1] + T[1] + S[2] + T[2] + S[3]
	if eval(A) == 7:
		print(A + '=7')
		exit()


op = ['+', '-']
(a, b, c, d) = map(str, input())
for o1 in op:
	for o2 in op:
		for o3 in op:
			form = a + o1 + b + o2 + c + o3 + d
			if eval(form) == 7:
				print(form + '=7')
				exit()


(a, b, c, d) = list(input())
ll = ['+', '-']
for x in ll:
	for y in ll:
		for z in ll:
			if eval(a + x + b + y + c + z + d) == 7:
				print(a + x + b + y + c + z + d + '=7')
				exit()


def insert_str(target, i, char):
	return target[:i] + char + target[i:]

def calc(target, i):
	nonlocal ans
	if ans != '':
		return
	if i == 7:
		if eval(target) == 7:
			ans = target + '=7'
			return ans
		return
	calc(insert_str(target, i, '+'), i + 2)
	calc(insert_str(target, i, '-'), i + 2)
S = input()
N = len(S)
ans = ''
calc(S, 1)
print(ans)


import sys
s = input()
for op1 in '+-':
	for op2 in '+-':
		for op3 in '+-':
			if eval(s[0] + op1 + s[1] + op2 + s[2] + op3 + s[3]) == 7:
				print(s[0] + op1 + s[1] + op2 + s[2] + op3 + s[3] + '=7')
				sys.exit(0)


ABCD = input()
op = '+-'
for i in range(pow(2, 3)):
	v = i
	f = str(ABCD[0])
	for j in range(1, 4):
		f += op[v % 2] + ABCD[j]
		v //= 2
	if eval(f) == 7:
		print('{}=7'.format(f))
		break


s = input()
for i in range(8):
	y = ''.join([s[k] + '+-'[i >> k & 1] for k in range(3)] + [s[-1]])
	if eval(y) == 7:
		print(y + '=7')
		exit()


s = input()
for x in '+-':
	for y in '+-':
		for z in '+-':
			sum = s[0] + x + s[1] + y + s[2] + z + s[3]
			if eval(sum) == 7:
				print(sum + '=7')
				exit()


s = input()
op = ['+', '-']
for i in range(2 ** (len(s) - 1)):
	t = s[0]
	for j in range(len(s) - 1):
		t += op[i >> j & 1] + s[j + 1]
	if eval(t) == 7:
		ans = t + '=7'
print(ans)


e = input()
op = ('+', '-')
for i in range(8):
	t = ''
	for j in range(4):
		k = i >> j & 1
		t += e[j] + op[k]
	t = t[:-1]
	if eval(t) == 7:
		print(t + '=7')
		break


(a, b, c, d) = list(input())
sign = '+-'
for i in range(2):
	for j in range(2):
		for k in range(2):
			if eval(a + sign[i] + b + sign[j] + c + sign[k] + d) == 7:
				print(str(a + sign[i] + b + sign[j] + c + sign[k] + d) + '=7')
				return


a = input()
for i in range(8):
	f = a[0]
	for j in range(3):
		f += '+-'[(i >> j) % 2]
		f += a[j + 1]
	if eval(f) == 7:
		print(f + '=7')
		exit()


(a, b, c, d) = list(input())
op = ['+', '-']
for i in op:
	for j in op:
		for k in op:
			formula = a + i + b + j + c + k + d
			if eval(formula) == 7:
				print(formula + '=7')
				exit()


a = input()

def dfs(i, f):
	if i == 3:
		if eval(f) == 7:
			print(f + '=7')
			exit()
	else:
		dfs(i + 1, f + '+' + a[i + 1])
		dfs(i + 1, f + '-' + a[i + 1])
print(dfs(0, a[0]))


a = input()
for x in range(1 << 3):
	s = a[0]
	for i in range(3):
		if x & 1 << i:
			s += '+'
		else:
			s += '-'
		s += a[i + 1]
	if eval(s) == 7:
		print(s + '=7')
		exit()


(a, b, c, d) = list(input())
from itertools import product
for p in product(['+', '-'], repeat=3):
	s = a + p[0] + b + p[1] + c + p[2] + d
	if eval(s) == 7:
		print(s + '=7')
		exit()


A = input()
for i in range(8):
	f = A[0]
	for j in range(3):
		f += '-+'[i >> j & 1] + A[j + 1]
	if eval(f) == 7:
		print(f + '=7')
		break


S = str(input())
sign = '+-'
for i in range(2 ** 3):
	t = ''.join([S[0]] + [sign[i >> k & 1] + s for (k, s) in enumerate(S[1:])])
	if eval(t) == 7:
		print(t + '=7')
		exit()


(a, b, c, d) = input()
op = ['+', '-']
for i in op:
	for j in op:
		for k in op:
			result = a + i + b + j + c + k + d
			if eval(result) == 7:
				print(result + '=7')
				exit()


import itertools
s = list(input())
ops = itertools.product('+-', repeat=3)
for (x, y, z) in ops:
	if eval(s[0] + x + s[1] + y + s[2] + z + s[3]) == 7:
		print(s[0] + x + s[1] + y + s[2] + z + s[3] + '=7')
		exit()


s = input()
for i in range(2 ** 3):
	op = format(i, '03b')
	op = op.replace('1', '+').replace('0', '-')
	st = s[0] + op[0] + s[1] + op[1] + s[2] + op[2] + s[3]
	if eval(st) == 7:
		print(st + '=7')
		break


import itertools
import sys
sys.setrecursionlimit(10 ** 6)
(a, b, c, d) = [int(i) for i in str(input())]
for (i, j, k) in itertools.product([1, -1], repeat=3):
	if a + b * i + c * j + d * k == 7:
		break
if i == 1:
	i = '+'
else:
	i = '-'
if j == 1:
	j = '+'
else:
	j = '-'
if k == 1:
	k = '+'
else:
	k = '-'
print('{}{}{}{}{}{}{}=7'.format(a, i, b, j, c, k, d))


(a, b, c, d) = input()
op = ['+', '-']
ans = ''
for i in range(2):
	for j in range(2):
		for k in range(2):
			if eval(a + op[i] + b + op[j] + c + op[k] + d) == 7:
				ans = a + op[i] + b + op[j] + c + op[k] + d + '=7'
print(ans)


def main():
	S = list(input())
	(A, B, C, D) = list(map(int, S))
	if A + B + C + D == 7:
		print('{}+{}+{}+{}=7'.format(A, B, C, D))
		return
	if A + B + C - D == 7:
		print('{}+{}+{}-{}=7'.format(A, B, C, D))
		return
	if A + B - C + D == 7:
		print('{}+{}-{}+{}=7'.format(A, B, C, D))
		return
	if A + B - C - D == 7:
		print('{}+{}-{}-{}=7'.format(A, B, C, D))
		return
	if A - B + C + D == 7:
		print('{}-{}+{}+{}=7'.format(A, B, C, D))
		return
	if A - B + C - D == 7:
		print('{}-{}+{}-{}=7'.format(A, B, C, D))
		return
	if A - B - C + D == 7:
		print('{}-{}-{}+{}=7'.format(A, B, C, D))
		return
	if A - B - C - D == 7:
		print('{}-{}-{}-{}=7'.format(A, B, C, D))
		return

def __starting_point():
	main()
__starting_point()


s = input()
p = ['+', '-']
for i in range(8):
	t = s
	for j in range(3):
		t = t[:3 - j] + p[i >> j & 1] + t[3 - j:]
	if eval(t) == 7:
		print(t + '=7')
		exit()


T = input()
for i in range(2 ** 3):
	t = ''
	for j in range(4):
		t += T[j]
		if i >> j & 1:
			t += '+'
		elif j != 3:
			t += '-'
	if eval(t) == 7:
		print(t + '=7')
		break


import sys
(a, b, c, d) = input()
for i in ['+', '-']:
	for j in ['+', '-']:
		for k in ['+', '-']:
			if eval(a + i + b + j + c + k + d) == 7:
				print(a + i + b + j + c + k + d + '=7')
				sys.exit()


from itertools import product
A = list(input())
for x in product(('+', '-'), repeat=3):
	y = A[0] + x[0] + A[1] + x[1] + A[2] + x[2] + A[3]
	if eval(y) == 7:
		print(y + '=7')
		break


from itertools import product
S = list(input())
a = list(product(['+', '-'], repeat=3))
for i in a:
	shiki = S[0] + i[0] + S[1] + i[1] + S[2] + i[2] + S[3]
	if eval(shiki) == 7:
		print(shiki + '=7')
		exit()


n = input()
lis = ['+', '-']
for x in lis:
	for y in lis:
		for z in lis:
			p = n[0] + x + n[1] + y + n[2] + z + n[3]
			if eval(p) == 7:
				print(p + '=7')
				exit()


import itertools as its
(A, B, C, D) = input()
for p in its.product(['-', '+'], repeat=3):
	ans = eval(A + p[0] + B + p[1] + C + p[2] + D)
	if ans == 7:
		print(A + p[0] + B + p[1] + C + p[2] + D + '=7')
		break


import itertools
(A, B, C, D) = input()
for i in itertools.product(['+', '-'], repeat=3):
	if eval(A + i[0] + B + i[1] + C + i[2] + D) == 7:
		print(A + i[0] + B + i[1] + C + i[2] + D + '=7')
		exit()


A = input()
op = ['+', '-']
for bit in range(1 << 3):
	ans = A[0]
	for i in range(3):
		ans += op[bit >> i & 1] + A[i + 1]
	if eval(ans) == 7:
		print(ans + '=7')
		break


import itertools
(a, b, c, d) = input()
pm = ['+', '-']
for (pm1, pm2, pm3) in itertools.product(pm, repeat=3):
	ans = a + pm1 + b + pm2 + c + pm3 + d
	if eval(ans) == 7:
		print(ans + '=7')
		break


num = list(input())
op = ['+', '-']
for op1 in op:
	if op1 == '+':
		res1 = int(num[0]) + int(num[1])
	else:
		res1 = int(num[0]) - int(num[1])
	for op2 in op:
		if op2 == '+':
			res2 = res1 + int(num[2])
		else:
			res2 = res1 - int(num[2])
		for op3 in op:
			if op3 == '+':
				res3 = res2 + int(num[3])
			else:
				res3 = res2 - int(num[3])
			if res3 == 7:
				ans = num[0] + op1 + num[1] + op2 + num[2] + op3 + num[3] + '=7'
				print(ans)
				return


def kipp(i, f):
	if i == 3:
		if eval(f) == 7:
			print(f + '=7')
			exit()
	else:
		kipp(i + 1, f + '+' + s[i + 1])
		kipp(i + 1, f + '-' + s[i + 1])
s = input()
kipp(0, s[0])


(A, B, C, D) = input()
op = '+----'
for i in range(8):
	s = A + op[i & 4] + B + op[i & 2] + C + op[i & 1] + D
	if eval(s) == 7:
		print(s + '=7')
		break


def dfs(i, sum1, sum2):
	nonlocal ans
	if i == 4 and sum1 != 7:
		return 0
	elif i == 4 and sum1 == 7:
		ans = sum2 + '=7'
	else:
		dfs(i + 1, sum1 - int(s[i]), sum2 + '-' + s[i])
		dfs(i + 1, sum1 + int(s[i]), sum2 + '+' + s[i])
ans = ''
s = input()
dfs(1, int(s[0]), s[0])
print(ans)


(A, B, C, D) = input()
op = ['+++', '++-', '+-+', '-++', '+--', '-+-', '--+', '---']
for (op1, op2, op3) in op:
	ex = A + op1 + B + op2 + C + op3 + D
	if eval(ex) == 7:
		break
print(ex + '=7')


import sys
S = input()
(a, b, c, d) = (S[0], S[1], S[2], S[3])
lst = ['+', '-']
for i in lst:
	for j in lst:
		for k in lst:
			if eval(a + i + b + j + c + k + d + '==7'):
				print(a + i + b + j + c + k + d + '=7')
				sys.exit()


s = input()
l = ['+'] * 3 + ['']
for k in range(7):
	a = ''.join([i + j for (i, j) in zip(s, l)])
	if eval(a) == 7:
		print(a + '=7')
		break
	l = list(bin(k + 1)[2:].zfill(3).replace('0', '+').replace('1', '-')) + ['']


(a, b, c, d) = input()
for x in '+-':
	for y in '+-':
		for z in '+-':
			f = a + x + b + y + c + z + d
			if eval(f) == 7:
				print(f + '=7')
				exit()


import itertools
s = list(input())
for x in itertools.product(['-', '+'], repeat=3):
	ans = s[0] + x[0] + s[1] + x[1] + s[2] + x[2] + s[3]
	if eval(ans) == 7:
		print(ans + '=7')
		break


S = input()
for i in range(1 << 3):
	s = S[0:1]
	for j in range(3):
		s += '+-'[i >> j & 1] + S[j + 1:j + 2]
	if eval(s) == 7:
		print(s + '=7')
		break


import itertools
N = input()
OP = ['+', '-']
for op in itertools.product(OP, repeat=3):
	str = N[0] + op[0] + N[1] + op[1] + N[2] + op[2] + N[3]
	ans = eval(str)
	if ans == 7:
		print(str + '=7')
		break


S = input()
for i in range(8):
	s = S[0]
	for j in range(3):
		s += list('+-')[i >> j & 1] + S[j + 1]
	if eval(s) == 7:
		ans = s
print(ans + '=7')


N = input()
for i in range(8):
	S = [['+', '-'][i >> j & 1] for j in range(3)]
	seq = N[0] + S[0] + N[1] + S[1] + N[2] + S[2] + N[3]
	if eval(seq) == 7:
		print(seq + '=7')
		break


import sys

def solve(l, r):
	if r == '':
		if eval(l) == 7:
			print(l + '=7')
			sys.exit()
	else:
		solve(l + '+' + r[0], r[1:])
		solve(l + '-' + r[0], r[1:])
s = input()
solve(s[0], s[1:])


from itertools import product
(A, B, C, D) = input()
for (op1, op2, op3) in product('+-', repeat=3):
	exp = f'{A}{op1}{B}{op2}{C}{op3}{D}'
	if eval(exp) == 7:
		print(exp + '=7')
		exit()


(A, B, C, D) = list(input())
op = ['-', '+']
for i in range(2 ** 3):
	s = A + op[i & 1] + B + op[i >> 1 & 1] + C + op[i >> 2 & 1] + D
	if eval(s) == 7:
		print(s + '=7')
		exit()


def add(i, b):
	if i:
		return '-' + str(b)
	else:
		return '+' + str(b)

def main():
	S = input()
	(a, b, c, d) = (int(S[0]), int(S[1]), int(S[2]), int(S[3]))
	ans = ''
	for i in range(2):
		for j in range(2):
			for k in range(2):
				if a + (-1) ** i * b + (-1) ** j * c + (-1) ** k * d == 7:
					ans += str(a)
					ans += add(i, b)
					ans += add(j, c)
					ans += add(k, d)
					ans += '=7'
					print(ans)
					return
main()


(a, b, c, d) = input()
for f in [a + p + b + q + c + r + d for p in '+-' for q in '+-' for r in '+-']:
	if eval(f) == 7:
		print(f + '=7')
		break


s = input()
for bit in range(2 ** 3):
	c = s[0]
	for i in range(3):
		if bit >> i & 1:
			c += '+'
		else:
			c += '-'
		c += s[i + 1]
	if eval(c) == 7:
		print(c + '=7')
		exit()


s = input()
l = list(s)
for k in range(1 << len(s) - 1):
	x = l[0] + ''.join((('+' if k >> i & 1 else '-') + j for (i, j) in enumerate(l[1:])))
	if eval(x) == 7:
		print(x + '=7')
		break


import itertools
n = input()
(a, b, c, d) = n
for (i, j, k) in itertools.product(['+', '-'], repeat=3):
	if eval(a + i + b + j + c + k + d) == 7:
		print(a + i + b + j + c + k + d + '=7')
		exit()


s = input()
for i in range(8):
	e = bin(i)[2:].zfill(3).replace('0', '+').replace('1', '-') + '='
	x = ''.join((''.join(c) for c in zip(s, e)))[:-1]
	if eval(x) == 7:
		print(x + '=7')
		exit()


def a(t, i):
	if i == l:
		if eval(t) == 7:
			print(t + '=7')
			exit()
		return
	a(t + '+' + s[i + 1], i + 1)
	a(t + '-' + s[i + 1], i + 1)
s = input()
l = len(s) - 1
a(s[0], 0)


(a, b, c, d) = map(str, input())
p = ['+', '-']
for i in p:
	for j in p:
		for x in p:
			s = a + i + b + j + c + x + d
			if eval(s) == 7:
				print(s + '=7')
				exit()


from itertools import product
S = input()
l = ['+', '-']
for k in list(product(l, repeat=3)):
	ans = S[0] + k[0] + S[1] + k[1] + S[2] + k[2] + S[3]
	if eval(ans) == 7:
		print(ans + '=7')
		exit()


from itertools import product
(a, b, c, d) = list(input())
for (o, p, q) in product('-+', repeat=3):
	if eval(a + o + b + p + c + q + d) == 7:
		print(a + o + b + p + c + q + d + '=7')
		break


import itertools
S = input()
for op in itertools.product('-+', repeat=3):
	f = S[0] + op[0] + S[1] + op[1] + S[2] + op[2] + S[3]
	if eval(f) == 7:
		print(f + '=7')
		exit()


s = ''.join
(*i, l) = input()
for t in map(lambda x: format(x, '03b').translate(str.maketrans('01', '-+')), range(8)):
	h = s(map(s, zip(i, t))) + l
	if eval(h) == 7:
		print(h + '=7')
		break


def some(num):
	return '+' if num == 0 else '-'

def main():
	(a, b, c, d) = map(int, input())
	for i in range(2):
		for j in range(2):
			for v in range(2):
				op1 = some(i)
				op2 = some(j)
				op3 = some(v)
				if eval(f'a{op1}b{op2}c{op3}d') == 7:
					print(f'{a}{op1}{b}{op2}{c}{op3}{d}=7')
					return
main()


def f(a, b, i):
	if i == 4:
		if b == 7:
			print(a + '=7')
			exit()
	else:
		return (f(a + '+' + s[i], b + int(s[i]), i + 1), f(a + '-' + s[i], b - int(s[i]), i + 1))
s = input()
f(s[0], int(s[0]), 1)


(a, b, c, d) = input()
import itertools as it
for (p, q, r) in it.product('+-', repeat=3):
	f = a + p + b + q + c + r + d
	if eval(f) == 7:
		print(f + '=7')
		break


(A, B, C, D) = input()
ops = ('+', '-')
for op1 in ops:
	for op2 in ops:
		for op3 in ops:
			if eval(A + op1 + B + op2 + C + op3 + D + '==7'):
				print(A + op1 + B + op2 + C + op3 + D + '=7')
				exit()


(A, B, C, D) = map(int, input())
tfs = []
rt = str(A)
for bt in (True, False):
	for ct in (True, False):
		for dt in (True, False):
			tfs.append([bt, ct, dt])
for (bt, ct, dt) in tfs:
	tmp = 7 - A
	tmp = tmp - B if bt else tmp + B
	tmp = tmp - C if ct else tmp + C
	tmp = tmp - D if dt else tmp + D
	if tmp == 0:
		rt += '+' if bt else '-'
		rt += str(B)
		rt += '+' if ct else '-'
		rt += str(C)
		rt += '+' if dt else '-'
		rt += str(D)
		rt += '=7'
		break
print(rt)


from itertools import product
s = input()
for ops in product('+-', repeat=3):
	t = ''.join([a + b for (a, b) in zip(s, ops)])
	t += s[-1]
	if eval(t) == 7:
		print(t + '=7')
		exit()


S = input()
for a in '+-':
	for b in '+-':
		for c in '+-':
			ans = S[0] + a + S[1] + b + S[2] + c + S[3]
			if eval(ans) == 7:
				print(ans + '=7')
				exit()


s = ['+', '-']
t = input()
a = ''
from itertools import product
for v in product(s, repeat=3):
	a = t[0] + v[0] + t[1] + v[1] + t[2] + v[2] + t[3]
	if eval(a) == 7:
		break
print(a + '=7')


s = input()
for i in range(8):
	a = ''
	for j in range(3):
		a += s[j]
		if i & 1 << 2 - j:
			a += '+'
		else:
			a += '-'
	a += s[-1]
	if eval(a) == 7:
		print(a + '=7')
		break


S = input()
for i in range(1 << 3):
	s = S[0:1]
	for j in range(3):
		s += list('+-')[i >> j & 1] + S[j + 1:j + 2]
	if eval(s) == 7:
		res = s
print(res + '=7')


S = input()
for i in range(8):
	s = S[:1]
	for j in range(3):
		s += '+-'[i >> j & 1] + S[j + 1]
	if eval(s) == 7:
		print(s + '=7')
		break


l = list(input())
for i in range(8):
	p = ['+' if i & j else '-' for j in [1, 2, 4]]
	line = ''.join([v + o for (v, o) in zip(l, p)]) + l[3]
	if eval(line) == 7:
		print(line + '=7')
		break


from itertools import product
a = list(input())
for b in product(['+', '-'], repeat=3):
	if eval(a[0] + b[0] + a[1] + b[1] + a[2] + b[2] + a[3]) == 7:
		print(str(a[0] + b[0] + a[1] + b[1] + a[2] + b[2] + a[3] + '=7'))
		break


import itertools
L = input()
s = ['+', '-']
for (a, b, c) in itertools.product(s, s, s):
	f = L[0] + a + L[1] + b + L[2] + c + L[3]
	if eval(f) == 7:
		print(f + '=7')
		exit(0)


from itertools import product
(a, b, c, d) = input().strip()
for (e, f, g) in product(['+', '-'], repeat=3):
	s = a + e + b + f + c + g + d
	if eval(s + '==7'):
		print(s + '=7')
		exit()


(a, b, c, d) = input()
for (i, j, k) in map(lambda x: format(x, '03b').translate(str.maketrans('01', '-+')), range(8)):
	h = a + i + b + j + c + k + d
	if eval(h) == 7:
		print(h + '=7')
		break


ABCD = list(input())
(a, b, c, d) = (int(ABCD[0]), int(ABCD[1]), int(ABCD[2]), int(ABCD[3]))
if a + b + c + d == 7:
	print('{0}+{1}+{2}+{3}=7'.format(a, b, c, d))
elif a + b + c - d == 7:
	print('{0}+{1}+{2}-{3}=7'.format(a, b, c, d))
elif a + b - c + d == 7:
	print('{0}+{1}-{2}+{3}=7'.format(a, b, c, d))
elif a - b + c + d == 7:
	print('{0}-{1}+{2}+{3}=7'.format(a, b, c, d))
elif a - b - c + d == 7:
	print('{0}-{1}-{2}+{3}=7'.format(a, b, c, d))
elif a + b - c - d == 7:
	print('{0}+{1}-{2}-{3}=7'.format(a, b, c, d))
elif a - b + c - d == 7:
	print('{0}-{1}+{2}-{3}=7'.format(a, b, c, d))
elif a - b - c - d == 7:
	print('{0}-{1}-{2}-{3}=7'.format(a, b, c, d))


(c, *s) = input()
n = len(s)
for b in range(1 << n):
	t = c + ''
	for i in range(n):
		t += ['-', '+'][b >> i & 1] + s[i]
	if eval(t) == 7:
		print(t + '=7')
		exit()


S = input()
(a, b, c, d) = S
ops = ['+', '-']
for op1 in ops:
	for op2 in ops:
		for op3 in ops:
			x = a + op1 + b + op2 + c + op3 + d
			if eval(x) == 7:
				print(x + '=7')
				exit()


s = input()
(a, b, c, d) = (s[0], s[1], s[2], s[3])
for op1 in '+-':
	for op2 in '+-':
		for op3 in '+-':
			f = a + op1 + b + op2 + c + op3 + d
			if eval(f) == 7:
				print(f + '=7')
				exit()


(a, b, c, d) = tuple(input())
import itertools
n = 3
for i in itertools.product(['-', '+'], repeat=n):
	ans = a + i[0] + b + i[1] + c + i[2] + d
	if eval(ans) == 7:
		print(ans + '=7')
		exit()


S = input()
a = int(S[0])
b = int(S[1])
c = int(S[2])
d = int(S[3])
if a + b + c + d == 7:
	print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a + b + c - d == 7:
	print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a + b - c + d == 7:
	print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a + b - c - d == 7:
	print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a - b + c + d == 7:
	print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a - b + c - d == 7:
	print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a - b - c - d == 7:
	print('{}-{}-{}-{}=7'.format(a, b, c, d))
elif a - b - c + d == 7:
	print('{}-{}-{}+{}=7'.format(a, b, c, d))


(a, b, c, d) = list(map(int, list(input())))
if a + b + c + d == 7:
	print('{}+{}+{}+{}=7'.format(a, b, c, d))
elif a + b + c - d == 7:
	print('{}+{}+{}-{}=7'.format(a, b, c, d))
elif a + b - c + d == 7:
	print('{}+{}-{}+{}=7'.format(a, b, c, d))
elif a - b + c + d == 7:
	print('{}-{}+{}+{}=7'.format(a, b, c, d))
elif a + b - c - d == 7:
	print('{}+{}-{}-{}=7'.format(a, b, c, d))
elif a - b - c + d == 7:
	print('{}-{}-{}+{}=7'.format(a, b, c, d))
elif a - b + c - d == 7:
	print('{}-{}+{}-{}=7'.format(a, b, c, d))
elif a - b - c - d == 7:
	print('{}-{}-{}-{}=7'.format(a, b, c, d))


import itertools
ads = ['+', '+', '+', '-', '-', '-']
s = input()
q = list(itertools.permutations(ads, 3))
for j in range(len(q)):
	ans = int(s[0])
	al = ''
	for k in range(3):
		if q[j][k] == '+':
			ans += int(s[k + 1])
		else:
			ans -= int(s[k + 1])
		al += q[j][k]
		al += s[k + 1]
	if ans == 7:
		print(s[0] + al + '=7')
		break


n = input()
for i in range(2 ** 3):
	co = ['-', '-', '-']
	for j in range(3):
		if i >> j & 1:
			co[2 - j] = '+'
	eq = n[0] + co[0] + n[1] + co[1] + n[2] + co[2] + n[3]
	if eval(eq) == 7:
		ans = eq
print(ans, end='')
print('=7')


n = input()

def dfs(i, l):
	if i == 3:
		return l + '=7' if eval(l) == 7 else ''
	return dfs(i + 1, l + '+' + n[i + 1]) or dfs(i + 1, l + '-' + n[i + 1])
print(dfs(0, n[0]))


S = input()
o = ['-', '+']
for h in o:
	for i in o:
		for j in o:
			if 7 == eval(S[0] + h + S[1] + i + S[2] + j + S[3]):
				print(S[0] + h + S[1] + i + S[2] + j + S[3] + '=7')
				exit()


S = input()
(A, B, C, D) = (int(S[0]), int(S[1]), int(S[2]), int(S[3]))
if A + B + C + D == 7:
	print(str(A) + '+' + str(B) + '+' + str(C) + '+' + str(D) + '=7')
elif A + B + C - D == 7:
	print(str(A) + '+' + str(B) + '+' + str(C) + '-' + str(D) + '=7')
elif A + B - C + D == 7:
	print(str(A) + '+' + str(B) + '-' + str(C) + '+' + str(D) + '=7')
elif A + B - C - D == 7:
	print(str(A) + '+' + str(B) + '-' + str(C) + '-' + str(D) + '=7')
elif A - B + C + D == 7:
	print(str(A) + '-' + str(B) + '+' + str(C) + '+' + str(D) + '=7')
elif A - B + C - D == 7:
	print(str(A) + '-' + str(B) + '+' + str(C) + '-' + str(D) + '=7')
elif A - B - C + D == 7:
	print(str(A) + '-' + str(B) + '-' + str(C) + '+' + str(D) + '=7')
else:
	print(str(A) + '-' + str(B) + '-' + str(C) + '-' + str(D) + '=7')


abcd = input()
for i in range(1 << 3):
	formula = abcd[0]
	for j in range(3):
		formula += '+-'[(i >> j) % 2]
		formula += abcd[j + 1]
	if eval(formula) == 7:
		print(formula + '=7')
		exit()


(A, B, C, D) = list(input())
try:
	for op1 in '+-':
		for op2 in '+-':
			for op3 in '+-':
				f = A + op1 + B + op2 + C + op3 + D
				if eval(f) == 7:
					raise f
except:
	print(f + '=7')


s = input()
op = ['+', '-']
for i in op:
	for j in op:
		for k in op:
			f = s[0] + i + s[1] + j + s[2] + k + s[3]
			if eval(f) == 7:
				print(f + '=7')
				exit()


(a, b, c, d) = map(str, input())
l = ['+', '-']
for i in l:
	for j in l:
		for k in l:
			if eval(a + i + b + j + c + k + d) == 7:
				print(a + i + b + j + c + k + d + '=7')
				exit()


from itertools import product
(A, B, C, D) = input().strip()
ops = '+-'
for (op1, op2, op3) in product(ops, ops, ops):
	if eval(A + op1 + B + op2 + C + op3 + D) == 7:
		break
print(A + op1 + B + op2 + C + op3 + D + '=7')


s = input()
a = s[0]
b = s[1]
c = s[2]
d = s[3]
for i in ['+', '-']:
	for j in ['+', '-']:
		for k in ['+', '-']:
			f = a + i + b + j + c + k + d
			if eval(f) == 7:
				print(f + '=7')
				exit()


s = input()
for a in '+-':
	for b in '+-':
		for c in '+-':
			t = s[0] + a + s[1] + b + s[2] + c + s[3]
			if eval(t) == 7:
				print(t + '=7')
				exit()


s = input()
op = ['+', '-']
for op1 in op:
	for op2 in op:
		for op3 in op:
			tmp = s[0] + op1 + s[1] + op2 + s[2] + op3 + s[3]
			if eval(tmp) == 7:
				ans = tmp
print(ans + '=7')


from itertools import product
x = list(input())
for v in list(product(['+', '-'], repeat=3)):
	ans = x[0] + v[0] + x[1] + v[1] + x[2] + v[2] + x[3]
	if eval(ans) == 7:
		break
print(''.join(ans) + '=7')


def kipp(i, f):
	if i == 3:
		if eval(f) == 7:
			print(f + '=7')
			exit()
	else:
		kipp(i + 1, f + '+' + a[i + 1])
		kipp(i + 1, f + '-' + a[i + 1])
a = list(input())
kipp(0, a[0])


from itertools import product
(a, b, c, d) = input()
for (op1, op2, op3) in product(['+', '-'], repeat=3):
	eq = a + op1 + b + op2 + c + op3 + d
	if eval(eq) == 7:
		print(eq + '=7')
		break


from itertools import product
s = input().strip()
for x in product(('+', '-'), repeat=3):
	y = s[0] + x[0] + s[1] + x[1] + s[2] + x[2] + s[3]
	if eval(y) == 7:
		break
print(y + '=7')


s = input()
print(filter(lambda x: eval(x) == 7, [''.join(sum(zip(s, ['+' if bit >> i & 1 == 1 else '-' for i in range(4)]), ()))[:-1] for bit in range(1 << 3)]).__next__() + '=7')


(a, b, c, d) = list(input())
op = lambda i, a: '+' if i & a else '-'
for i in range(8):
	s = a + op(i, 1) + b + op(i, 2) + c + op(i, 4) + d
	if eval(s) == 7:
		print(s + '=7')
		exit()


(A, B, C, D) = input()
E = '+-'
for i in E:
	for j in E:
		for k in E:
			s = A + i + B + j + C + k + D
			if eval(s) == 7:
				print(s + '=7')
				exit()


ABCD = input()
A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])
if 7 == A + B + C + D:
	print(f'{A}+{B}+{C}+{D}=7')
elif 7 == A + B + C - D:
	print(f'{A}+{B}+{C}-{D}=7')
elif 7 == A + B - C - D:
	print(f'{A}+{B}-{C}-{D}=7')
elif 7 == A - B - C - D:
	print(f'{A}-{B}-{C}-{D}=7')
elif 7 == A + B - C + D:
	print(f'{A}+{B}-{C}+{D}=7')
elif 7 == A - B - C + D:
	print(f'{A}-{B}-{C}+{D}=7')
elif 7 == A - B + C + D:
	print(f'{A}-{B}+{C}+{D}=7')
elif 7 == A - B + C - D:
	print(f'{A}-{B}+{C}-{D}=7')


import itertools
(A, B, C, D) = input()
for p in itertools.product(['+', '-'], repeat=3):
	equ = A + p[0] + B + p[1] + C + p[2] + D
	if eval(equ) == 7:
		print(equ + '=7')
		break


S = input()
p = ['+', '-']
for i in range(2 ** 3):
	t = S[0]
	for j in range(3):
		t += p[i >> j & 1] + S[j + 1]
	judge = eval(t)
	if judge == 7:
		print(t + '=7')
		break


A = list(map(int, list(input())))

def sign(x):
	return '+' if x == 1 else '-'
for i in [1, -1]:
	for j in [1, -1]:
		for k in [1, -1]:
			if A[0] + A[1] * i + A[2] * j + A[3] * k == 7:
				print(str(A[0]) + sign(i) + str(A[1]) + sign(j) + str(A[2]) + sign(k) + str(A[3]) + '=7')
				return


S = input()
op = ['+', '-']
for a in op:
	for b in op:
		for c in op:
			shiki = S[0] + a + S[1] + b + S[2] + c + S[3]
			if eval(shiki) == 7:
				print(shiki + '=7')
				exit()


from itertools import product
(A, B, C, D) = list(input())
for X in product(['+', '-'], repeat=3):
	s = A
	for (x, y) in zip(X, [B, C, D]):
		s += x + y
	if eval(s) == 7:
		print(s + '=7')
		exit()


s = list(input())
d = ['+', '-']
for i in d:
	for j in d:
		for k in d:
			if eval(s[0] + i + s[1] + j + s[2] + k + s[3]) == 7:
				ans = s[0] + i + s[1] + j + s[2] + k + s[3]
print(ans + '=7')