OpenKattis
Kattis Set 10

#### Start

2020-03-23 05:15 AKDT

## Kattis Set 10

#### End

2020-03-30 01:30 AKDT
The end is near!
Contest is over.
Not yet started.
Contest is starting in -247 days 23:35:06

164:15:00

0:00:00

# Problem HThe Magical 3

There’s no doubt about it, three is a magical number. Two’s company, but three’s a crowd, no one ever talks about 2 blind mice, and there are three members in an ACM ICPC team.

Even more magically, almost all integers can be represented as a number that ends in 3 in some numeric base, sometimes in more than one way. Consider the number 11, which is represented as 13 in base 8 and 23 in base 4. For this problem, you will find the smallest base for a given number so that the number’s representation in that base ends in 3.

## Input

Each line of the input contains one nonnegative integer $n$. The value $n = 0$ represents the end of the input and should not be processed. All input integers are less than $2^{31}$. There are no more than $1\, 000$ nonzero values of $n$.

## Output

For each nonzero value of $n$ in the input, print on a single line the smallest base for which the number has a representation that ends in 3. If there is no such base, print instead “No such base”.

Sample Input 1 Sample Output 1
11
123
104
2
3
0

4
4
101
No such base
4