题目描述
Pankaj is a loiter person,
at once his mentor who is a great mathematician call him for some urgent work
but due to his bad habit Pankaj forgot about it
for that his mentor was very angry and want to punish him
so he gives a series of real numbers (each number has value less than one) to Pankaj
for calculate the minimum value of P and Q if possible,where (P/Q==NUMBER) .
you are Pankaj's friend and want to help him by calculating values of P and Q
but you have not sufficient time to do this manually so you decided to make a program for that.
"..." will be used to denote the infinite recurring sequence of any digits, if there is no one repetition in given string till "..." then there will be a non recurring sequence up-to infinite.
note: in case of any conflict in recurrence we will take recurrence of maximum length.
if you do not know about rational number then go through this link enter link description here
input:
First line contains total numbers t which will be followed by t strings each string has a number.
output:
if possible to calculate print the minimum Value of P and Q.
constraints:
1 ≤ t=<100
3 ≤ string length(input) ≤ 16
SAMPLE INPUT
3
0.333...
0.4345...
0.3
SAMPLE OUTPUT
P=1 Q=3
P=3 Q=10
输入格式
见题面
输出格式
见题面