Problem:
Score : 300 points

Problem Statement

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 1

1222

Sample Output 1

1+2+2+2=7

This is the only valid solution.

Sample Input 2

0290

Sample Output 2

0-2+9+0=7

0 - 2 + 9 - 0 = 7 is also a valid solution.

Sample Input 3

3242

Sample Output 3

3+2+4-2=7

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;

// https://atcoder.jp/contests/abc079/tasks/abc079_c
namespace TrainTicket
{
    public class Program
    {
        private class Node
        {
            private enum OpType
            {
                None,
                Add,
                Sub,
            }

            private const int ExpectedValue = 7;
            private int m_value;
            private Node m_add;
            private Node m_sub;
            private OpType m_op;

            private Node(int value, OpType op)
            {
                m_value = value;
                m_op = op;
            }

            public Node(int value) : this(value, OpType.None)
            {
            }

            public void Insert(int value)
            {
                if (m_add == null)
                {
                    m_add = new Node(value, OpType.Add);
                }
                else
                {
                    m_add.Insert(value);
                }

                if (m_sub == null)
                {
                    m_sub = new Node(value, OpType.Sub);
                }
                else
                {
                    m_sub.Insert(value);
                }
            }

            public bool Exec()
            {
                return Eval();
            }

            private bool Eval(int value = 0, string s = "", int count = 0)
            {
                var result = 0;
                var expr = s;
                var found = false;
                var hasNext = (m_add != null) || (m_sub != null);

                if (count > 0)
                {
                    if (m_op == OpType.Add)
                    {
                        result = value + m_value;
                        expr += $"+{m_value}";
                    }
                    else if (m_op == OpType.Sub)
                    {
                        result = value - m_value;
                        expr += $"-{m_value}";
                    }
                }
                else
                {
                    result = m_value;
                    expr = m_value.ToString();
                }

                if (m_add != null && m_add.Eval(result, expr, count + 1)) { found = true; }
                if (m_sub != null && m_sub.Eval(result, expr, count + 1)) { found = true; }
                if (result == ExpectedValue && !hasNext)
                {
                    Console.WriteLine($"{expr}={result}");
                    found = true;
                }
                return found;
            }
        }

        static bool TryParse(string s, out int value)
        {
            if (!int.TryParse(s, out value) || !(value >= 0 && value <= 9))
            {
                return false;
            }
            return true;
        }

        static void Logic(string s)
        {
            if (s.Length != 4)
            {
                return;
            }

            var A = 0;
            var B = 0;
            var C = 0;
            var D = 0;
            if (!TryParse(s[0].ToString(), out A)) { return; }
            if (!TryParse(s[1].ToString(), out B)) { return; }
            if (!TryParse(s[2].ToString(), out C)) { return; }
            if (!TryParse(s[3].ToString(), out D)) { return; }

            var node = new Node(A);
            node.Insert(B);
            node.Insert(C);
            node.Insert(D);
            node.Exec();
        }

        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            Logic(input);
        }
    }
}