#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 /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int n;
  int biubiu, haihai, ans;
  scanf("%d", &n);
  do {
    scanf("%d%d", &biubiu, &haihai);
    ans = 0;
    while (biubiu > 0) {
      biubiu -= haihai;
      biubiu <<= 1;
      haihai *= 1.05;
      if (biubiu > 1000000)
        biubiu = 1000000;
      ++ans;
    }
    printf("%d\n", ans);
  } while (--n);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed4(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xec0(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    11b6 <main+0x96>
mov    -0x10(%rbp),%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0xc(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe77(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0xf4240,-0xc(%rbp)
jle    11a8 <main+0x88>
movl   $0xf4240,-0xc(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115e <main+0x3e>
mov    -0x14(%rbp),%esi
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jne    1141 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xed8(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xec3(%rip),%r14
lea    0x10(%rsp),%r15
lea    0xc(%rsp),%r12
lea    0xeb7(%rip),%rbx
jmp    116f <main+0x4f>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <printf@plt>
addl   $0xffffffff,0x14(%rsp)
je     11d4 <main+0xb4>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
mov    $0x0,%esi
test   %eax,%eax
jle    1160 <main+0x40>
xor    %esi,%esi
mov    0xc(%rsp),%ecx
movsd  0xe66(%rip),%xmm1
nopw   0x0(%rax,%rax,1)
sub    %ecx,%eax
mov    %eax,%edx
add    %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
cmp    $0xf4240,%edx
mov    $0xf4240,%eax
cmovl  %edx,%eax
add    $0x1,%esi
test   %edx,%edx
jg     11a0 <main+0x80>
mov    %eax,0x10(%rsp)
mov    %ecx,0xc(%rsp)
jmp    1160 <main+0x40>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [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
store i32 0, i32* %1
%6 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %31, %0
%8 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %3, i32* %4)
store i32 0, i32* %5
br label %9
9: ; preds = %25, %7
%10 = load i32, i32* %3
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = sub nsw i32 %14, %13
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = shl i32 %16, 1
store i32 %17, i32* %3
%18 = load i32, i32* %4
%19 = sitofp i32 %18 to double
%20 = fmul double %19, 1.050000e+00
%21 = fptosi double %20 to i32
store i32 %21, i32* %4
%22 = load i32, i32* %3
%23 = icmp sgt i32 %22, 1000000
br i1 %23, label %24, label %25
24: ; preds = %12
store i32 1000000, i32* %3
br label %25
25: ; preds = %24, %12
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %9
28: ; preds = %9
%29 = load i32, i32* %5
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %28
%32 = load i32, i32* %2
%33 = add nsw i32 %32, -1
store i32 %33, i32* %2
%34 = icmp ne i32 %33, 0
br i1 %34, label %7, label %35
35: ; preds = %31
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [4 x i8] c"%d\0A\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* %1)
br label %8
8: ; preds = %28, %0
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%10 = load i32, i32* %2
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i32, i32* %3
br label %14
14: ; preds = %12, %14
%15 = phi i32 [ %25, %14 ], [ 0, %12 ]
%16 = phi i32 [ %24, %14 ], [ %10, %12 ]
%17 = phi i32 [ %22, %14 ], [ %13, %12 ]
%18 = sub nsw i32 %16, %17
%19 = shl i32 %18, 1
%20 = sitofp i32 %17 to double
%21 = fmul double %20, 1.050000e+00
%22 = fptosi double %21 to i32
%23 = icmp slt i32 %19, 1000000
%24 = select i1 %23, i32 %19, i32 1000000
%25 = add nuw nsw i32 %15, 1
%26 = icmp sgt i32 %19, 0
br i1 %26, label %14, label %27
27: ; preds = %14
store i32 %24, i32* %2
store i32 %22, i32* %3
br label %28
28: ; preds = %27, %8
%29 = phi i32 [ %25, %27 ], [ 0, %8 ]
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %1
%32 = add nsw i32 %31, -1
store i32 %32, i32* %1
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %8
34: ; preds = %28
ret i32 0
}