#P1473. Zero Sum Expressions

    ID: 14759 Type: Default 1000ms 256MiB

Zero Sum Expressions

Zero Sum Expressions

Given an increasing sequence of digits from 1 to N, insert between each pair of consecutive digits one of the following: a plus sign (+), a minus sign (-), or a blank space (which concatenates the digits). Do not insert any operator before the first digit.

Your task is to list all expressions that evaluate to 0. When a blank is used, the digits are concatenated into a multi-digit number. The final result of the expression must be exactly 0.

inputFormat

The input consists of a single integer N (3 ≤ N ≤ 9) representing the length of the digit sequence.

outputFormat

Output each valid expression (that evaluates to 0) on a separate line in lexicographical order. Operators are inserted between the digits as described.

sample

3
1+2-3