Restoring the Erased Equation (Large)

Fill every ? with a digit so the addition or subtraction holds without leading zeros and the whole equation is lexicographically smallest.

Medium7Dynamic programmingGreedyMathNo attempts yetTime limit5sMemory limit512 MB

Problem

A publisher made an arithmetic practice book for elementary school students. A rival publisher secretly edited the manuscript right before printing and erased some of the digits in the equations. The erased positions have to be filled back in.

An equation follows these rules.

  • An equation has the form number operator number = number.
  • The operator is addition + or subtraction -.
  • Every number is a non-negative integer. A number with two or more digits does not start with 0, and zero is written as the single digit 0.
  • Each erased position is shown as one ? character.
  • Replacing a ? with a digit does not change how many digits a number has.
  • There is exactly one space between a number and the operator, and between a number and =. The equation has no spaces at its start or end.
  • The equation was correct before the digits were erased, so at least one restoration satisfies every rule.

Input

The first line contains the number of test cases TT. Each of the next TT lines contains the equation of one test case.

Limits

  • 1T1001 \le T \le 100
  • 11 \le length of an equation 250\le 250

Output

For each test case, print one line in the form Case #x: y, where x is the case number starting from 1 and y is the restored equation.

If several restorations are possible, compare the whole equation as a string and print the smallest one in lexicographic order. For example, ? + ? = 2 can be restored as 0 + 2 = 2, 1 + 1 = 2, or 2 + 0 = 2, so the answer is 0 + 2 = 2.