Hide

Problem A
Blackboard Numbers

/problems/primes2/file/statement/en/img-0001.jpg

Your maths teacher, Professor Prime, likes writing integers on the blackboard at the end of class. You have been taking notes all semester, and have noticed two things:

  1. There is an equal chance of the number being written in binary, octal, decimal, and hexadecimal.

  2. There seems to be no apparent connection between them.

Professor Prime has given you the task of finding the connection between the numbers. He claims that there exists a function $f$, such that on day $i$, $f(i)$ would produce the number he wrote on the blackboard. He seems to think that this task should be relatively simple, given that he has been doing it for a very long time, and you have a lot of numbers to plug into the function.

You have decided not to complete his task, and rather calculate the probability that the number is a prime. You don’t remember why you decided to do so, but here we are, so I guess you just have to do it.

Input

The first line of the input consists of a single integer, $T$, the number of test cases.
Each of the $T$ test cases consists of a single line with a string representing the number he wrote that day.

  • $1 \leq T \leq 200$

  • Each number will consist of the characters 0-9 and A-F.

  • Each number will have between 1 and 10 characters.

  • Numbers in binary, octal, decimal and hexadecimal are numbers written in base 2, 8, 10 and 16, respectively. Hexadecimal numbers use extra digits A-F for 10-15.

  • A prime number is an integer greater than 1 that has no positive divisors other than 1 and itself.

Output

For each test case, output the probability that the number is a prime as a reduced fraction (that is, the greatest common divisor of the numerator and denominator is 1).

Sample Input 1 Sample Output 1
3
10
B
4
1/4
1/1
0/1

Please log in to submit a solution to this problem

Log in