SP18302 IDC1948 - Identity crisis
Description
For every given number n we define x(n) as distance from n to the first number after n in form of 99...99. For example x(100)=899, x(45)=54, etc. Given several n numbers you have to find the Z $ _{p} $ , where x(n)≡n mod p.
Input Format
First line of input icontains one number T (T
Output Format
In each line you have to write one number - the least p>1 that x(n)≡n mod p. If there is no such p the line should contain -1.