#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int calcgcd(int, int);
int countdigits(int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int a, b, digits, num, gcd;
  int t;
  scanf("%d", &t);
  while (t--) {
    a = b = 0;
    scanf("%d.%d", &a, &b);
    if (b == 0)
      printf("1\n");
    else {
      digits = countdigits(b);
      num = pow(10, digits);
      gcd = calcgcd(b, num);
      printf("%d\n", num / gcd);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9d(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     120b <main+0xbb>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xe66(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   1060 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11c6 <main+0x76>
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1206 <main+0xb6>
mov    -0xc(%rbp),%edi
call   1040 <countdigits@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    $0xa,%edi
call   1070 <pow@plt>
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
call   1050 <calcgcd@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1171 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xe8e(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
subl   $0x1,0x10(%rsp)
jb     121f <main+0xbf>
lea    0xe6d(%rip),%r14
lea    0x14(%rsp),%r15
lea    0xc(%rsp),%rbx
lea    0xe66(%rip),%r12
lea    0xe5b(%rip),%r13
jmp    11e8 <main+0x88>
nopl   (%rax)
call   1050 <countdigits@plt>
mov    $0xa,%edi
mov    %eax,%esi
call   1080 <pow@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%edi
mov    %eax,%esi
call   1060 <calcgcd@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
subl   $0x1,0x10(%rsp)
jb     121f <main+0xbf>
movl   $0x0,0xc(%rsp)
movl   $0x0,0x14(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1070 <scanf@plt>
mov    0xc(%rsp),%edi
test   %edi,%edi
jne    11b0 <main+0x50>
mov    %r12,%rdi
call   1030 <puts@plt>
subl   $0x1,0x10(%rsp)
jae    11e8 <main+0x88>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d.%d\00"
@.str.2 = [3 x i8] c"1\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
br label %9
9: ; preds = %31, %0
%10 = load i32, i32* %7
%11 = add nsw i32 %10, -1
store i32 %11, i32* %7
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %32
13: ; preds = %9
store i32 0, i32* %3
store i32 0, i32* %2
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%15 = load i32, i32* %3
%16 = icmp eq i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %13
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %31
19: ; preds = %13
%20 = load i32, i32* %3
%21 = call i32 @countdigits(i32 %20)
store i32 %21, i32* %4
%22 = load i32, i32* %4
%23 = call i32 @pow(i32 10, i32 %22)
store i32 %23, i32* %5
%24 = load i32, i32* %3
%25 = load i32, i32* %5
%26 = call i32 @calcgcd(i32 %24, i32 %25)
store i32 %26, i32* %6
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = sdiv i32 %27, %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %19, %17
br label %9
32: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d.%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [2 x i8] c"1\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = add nsw i32 %8, -1
store i32 %9, i32* %3
%10 = icmp eq i32 %8, 0
br i1 %10, label %28, label %11
11: ; preds = %0, %24
store i32 0, i32* %2
store i32 0, i32* %1
%12 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %1, i32* %2)
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %24
17: ; preds = %11
%18 = call i32 @countdigits(i32 %13)
%19 = call i32 @pow(i32 10, i32 %18)
%20 = load i32, i32* %2
%21 = call i32 @calcgcd(i32 %20, i32 %19)
%22 = sdiv i32 %19, %21
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %17, %15
%25 = load i32, i32* %3
%26 = add nsw i32 %25, -1
store i32 %26, i32* %3
%27 = icmp eq i32 %25, 0
br i1 %27, label %28, label %11
28: ; preds = %24, %0
ret i32 0
}