According to the Bible, 666 is the “number of the beast”. Indeed, in Revelation $\mit 13$:$\mit 18$ it is said:
“…count the number of the beast: for it is the
number of a man; and his number is 666.”
Many theologists have associated 666 with the Antichrist. Believe it or not, 666 has many interesting numerological properties. For instance,
Another curious property is that it is possible (there are exactly
two ways) to insert ‘+’ signs into the number 123456789 to
get 666:
and it is also possible (there is exactly one way) to do the same with
the number 987654321:
Let’s play numerology. Write a program such that, given two numbers
and
,
prints all the ways to insert ‘+’ signs into
so that the sum is
.
Input consists of several cases. Every case has two strictly positive natural numbers and , each not larger than . Assume that the leftmost digit of and of is never zero.
For every case, print all the ways to get by adding the digits of as explained above. The solutions must appear in lexicographical order. If no solution exists, state so.
Input
666 987654321 5 321 4 1003
Output
666 = 9 + 87 + 6 + 543 + 21 No solution for 5 321. 4 = 1 + 0 + 0 + 3 4 = 1 + 0 + 03 4 = 1 + 00 + 3 4 = 1 + 003