Magic

Given Y, count natural numbers X whose decimal digits reversed and added back to X give exactly Y.

Medium6MathImplementationNo attempts yetTime limit1sMemory limit128 MB

Problem

Mirko has thought of a top-secret natural number XX that holds the secret of ruling the universe. His best friend Slavko is drunk with power and wants to get hold of that number. While searching Mirko's drawers late at night, Slavko found a slip of paper. It says that the sum of XX and the mirror of XX is exactly YY.

The mirror of XX is formed by writing the decimal digits of XX in reverse order. For example, the mirror of 123123 is 321321, and the mirror of 520520 is 2525.

For a given YY, compute how many natural numbers XX satisfy this condition.

Input

The first line contains TT (1T5001 \le T \le 500), the number of test cases you must answer.

Each of the next TT lines contains one natural number YY (1Y10181 \le Y \le 10^{18}), as described in the statement.

Output

For each of the TT numbers YY, print one line with the number of distinct values of XX that produce exactly that YY.

The answer for each YY is completely independent of the lines before and after it in the input.

Hint

10=5+510 = 5 + 5

11=10+111 = 10 + 1

121=110+11=92+29=83+38=74+47=65+56=56+65=47+74=38+83=29+92121 = 110 + 11 = 92 + 29 = 83 + 38 = 74 + 47 = 65 + 56 = 56 + 65 = 47 + 74 = 38 + 83 = 29 + 92