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: introductory

Starter code:

Solutions:

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

#!/usr/bin/env python3
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)))


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

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 


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


# coding: utf-8
# Your code here!




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)






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

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

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


def dfs(i,sum1,sum2):
    nonlocal ans
    #print(sum1,sum2)
    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)

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

import itertools
L = ['+', '-']
s = list(input())
for l in itertools.product(L, repeat=3):
  if 7 == eval(s[0]+l[0]+s[1]+l[1]+s[2]+l[2]+s[3]):
    print(s[0]+l[0]+s[1]+l[1]+s[2]+l[2]+s[3]+'=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');return

# coding = SJIS

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

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

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

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

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

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


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');return

N = input()
n = str(N)
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")

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

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

# 解き直し
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()

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-26 23:24:58 +0900
# LastModified: 2020-09-26 23:33:37 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


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

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

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

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

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

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

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

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