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++14 (GCC 5.4.1) (judge verdict: Accepted)

#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
#include<map>
#include<set>
#include<utility>
#include<tuple>
using namespace std;
int myeval(string s) {
	int a = (int)s[0] - '0';
	int b = (int)s[2] - '0';
	int c = (int)s[4] - '0';
	int d = (int)s[6] - '0';
	int sum = a;
	if (s[1] == '+') sum += b;
	else sum -= b;
	if (s[3] == '+') sum += c;
	else sum -= c;
	if (s[5] == '+') sum += d;
	else sum -= d;
	return sum;
}
bool dfs(string abcd, string op, string &res) {
	string orig = res + op + abcd[0];
	res = orig;
	if (abcd.size() == 1) {
		int e = myeval(res);
		return e == 7 ;
	}
	else {
		string sub(abcd.begin() + 1, abcd.end());
		if(dfs(sub, "+", res)) return true;
		res = orig;
		return dfs(sub, "-", res);
	}
}

int main() {
	string s;
	cin >> s;
	string res(s.begin(), s.begin()+1);
	string ans;
	if (dfs(string(s.begin()+1, s.end()), "+", res)) ans = res;
	else
	{
		res = string(s.begin(), s.begin() + 1);
		if (dfs(string(s.begin()+1, s.end()), "-", res))ans = res;
	}
	cout << res + "=7"<<endl;
	return 0;
}