Our Base is Under Attack

All submissions for this problem are available.
Read problems statements in Mandarin Chinese, Russian and Vietnamese as well.
Chef has recently learned about number bases and is becoming fascinated.
Chef learned that for bases greater than ten, new digit symbols need to be introduced, and that the convention is to use the first few letters of the English alphabet. For example, in base 16, the digits are 0123456789ABCDEF. Chef thought that this is unsustainable; the English alphabet only has 26 letters, so this scheme can only work up to base 36. But this is no problem for Chef, because Chef is very creative and can just invent new digit symbols when she needs them. (Chef is very creative.)
Chef also noticed that in base two, all positive integers start with the digit 1! However, this is the only base where this is true. So naturally, Chef wonders: Given some integer N, how many bases b are there such that the baseb representation of N starts with a 1?
Input
The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
Each test case consists of one line containing a single integer N (in base ten).
Output
For each test case, output a single line containing the number of bases b, or INFINITY if there are an infinite number of them.
Constraints
Subtasks
Subtask #1 (16 points): 1 ≤ T ≤ 10^{3}
 0 ≤ N < 10^{3}
 1 ≤ T ≤ 10^{3}
 0 ≤ N < 10^{6}
 1 ≤ T ≤ 10^{3}
 0 ≤ N < 10^{12}
 1 ≤ T ≤ 10^{5}
 0 ≤ N < 10^{12}
Example
Input: 4 6 9 11 24 Output: 4 7 8 14
Explanation
In the first test case, 6 has a leading digit 1 in bases 2, 4, 5 and 6: 6_{10} = 110_{2} = 12_{4} = 11_{5} = 10_{6}.
Author:  kevinsogo 
Editorial  https://discuss.codechef.com/problems/BASE 
Tags  dec16, kevinsogo 
Date Added:  23112016 
Time Limit:  3 sec 
Source Limit:  50000 Bytes 
Languages:  C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 