python_code='

n=input();b=1
while b<n-2:
 m=n;r=0;b+=1
 while m/(r!=n):r=r*b+m%b;m/=b

'

for test_case in \
	0 1 2 3  4  6 11 19 47 53 79 103 389 997 1459 \
	5 7 8 9 10 13 16 43 48 61 62 101 113 211 1361
	do
		printf '%4d ' $test_case
		if python -c "$python_code" <<< $test_case; then
			echo true
		else
			echo false
		fi
done 2>&-