#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 *, unsigned long long);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int t, N, K, i, min, pos;
  unsigned long long int max, temp;
  int arr[100001][2];
  scanf("%d", &t);
  while (t--) {
    max = 1;
    scanf("%d%d", &N, &K);
    for (i = 0; i < N; i++) {
      scanf("%d", &arr[i][0]);
    }
    for (i = 0; i < N; i++) {
      scanf("%d", &arr[i][1]);
      temp = K / arr[i][0];
      temp *= arr[i][1];
      if (max < temp) {
        max = temp;
        pos = i;
      }
    }
    printf("%lld\n", max);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc3540,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec9(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     125c <main+0x13c>
movq   $0x1,-0x28(%rbp)
lea    0xe99(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b7 <main+0x97>
movslq -0x14(%rbp),%rax
lea    -0xc3540(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117d <main+0x5d>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1247 <main+0x127>
movslq -0x14(%rbp),%rax
lea    -0xc3540(%rbp),%rsi
shl    $0x3,%rax
add    %rax,%rsi
add    $0x4,%rsi
lea    0xe1b(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
movslq -0x14(%rbp),%rcx
cltd
idivl  -0xc3540(%rbp,%rcx,8)
cltq
mov    %rax,-0x30(%rbp)
movslq -0x14(%rbp),%rax
movslq -0xc353c(%rbp,%rax,8),%rax
ff
imul   -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jae    1234 <main+0x114>
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1239 <main+0x119>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11be <main+0x9e>
mov    -0x28(%rbp),%rsi
lea    0xdb3(%rip),%rdi
call   1030 <printf@plt>
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0xc3540,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc3518,%rsp
lea    0xeca(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x8(%rsp)
jae    115f <main+0x3f>
xor    %eax,%eax
add    $0xc3518,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe9c(%rip),%r15
lea    0xe98(%rip),%r13
jmp    1182 <main+0x62>
nop
mov    %r13,%rdi
mov    %r12,%rsi
call   1030 <printf@plt>
subl   $0x1,0x8(%rsp)
jb     114b <main+0x2b>
lea    0xe77(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0xc(%rsp),%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    $0x1,%r12d
cmpl   $0x0,0x4(%rsp)
jle    1170 <main+0x50>
lea    0x10(%rsp),%rbx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
add    $0x8,%rbx
cmp    %rax,%rbp
jl     11b0 <main+0x90>
test   %eax,%eax
jle    1170 <main+0x50>
mov    $0x1,%r12d
lea    0x14(%rsp),%r14
xor    %ebx,%ebx
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cltd
idivl  -0x4(%r14)
cltq
movslq (%r14),%rcx
imul   %rax,%rcx
cmp    %rcx,%r12
cmovb  %rcx,%r12
add    $0x1,%rbx
movslq 0x4(%rsp),%rax
add    $0x8,%r14
cmp    %rax,%rbx
jl     11e0 <main+0xc0>
jmp    1170 <main+0x50>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [6 x i8] c"%lld\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
%8 = alloca i64
%9 = alloca i64
%10 = alloca [100001 x [2 x i32]]
store i32 0, i32* %1
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %12
12: ; preds = %68, %0
%13 = load i32, i32* %2
%14 = add nsw i32 %13, -1
store i32 %14, i32* %2
%15 = icmp ne i32 %13, 0
br i1 %15, label %16, label %71
16: ; preds = %12
store i64 1, i64* %8
%17 = 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 %18
18: ; preds = %28, %16
%19 = load i32, i32* %5
%20 = load i32, i32* %3
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %31
22: ; preds = %18
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [100001 x [2 x i32]], [100001 x [2 x i32]]* %10, i64 0, i64 %24
%26 = getelementptr inbounds [2 x i32], [2 x i32]* %25, i64 0, i64 0
%27 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %26)
br label %28
28: ; preds = %22
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %18
31: ; preds = %18
store i32 0, i32* %5
br label %32
32: ; preds = %65, %31
%33 = load i32, i32* %5
%34 = load i32, i32* %3
%35 = icmp slt i32 %33, %34
br i1 %35, label %36, label %68
36: ; preds = %32
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100001 x [2 x i32]], [100001 x [2 x i32]]* %10, i64 0, i64 %38
%40 = getelementptr inbounds [2 x i32], [2 x i32]* %39, i64 0, i64 1
%41 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %40)
%42 = load i32, i32* %4
%43 = load i32, i32* %5
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100001 x [2 x i32]], [100001 x [2 x i32]]* %10, i64 0, i64 %44
%46 = getelementptr inbounds [2 x i32], [2 x i32]* %45, i64 0, i64 0
%47 = load i32, i32* %46
%48 = sdiv i32 %42, %47
%49 = sext i32 %48 to i64
store i64 %49, i64* %9
%50 = load i32, i32* %5
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds [100001 x [2 x i32]], [100001 x [2 x i32]]* %10, i64 0, i64 %51
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %52, i64 0, i64 1
%54 = load i32, i32* %53
%55 = sext i32 %54 to i64
%56 = load i64, i64* %9
%57 = mul i64 %56, %55
store i64 %57, i64* %9
%58 = load i64, i64* %8
%59 = load i64, i64* %9
%60 = icmp ult i64 %58, %59
br i1 %60, label %61, label %64
61: ; preds = %36
%62 = load i64, i64* %9
store i64 %62, i64* %8
%63 = load i32, i32* %5
store i32 %63, i32* %7
br label %64
64: ; preds = %61, %36
br label %65
65: ; preds = %64
%66 = load i32, i32* %5
%67 = add nsw i32 %66, 1
store i32 %67, i32* %5
br label %32
68: ; preds = %32
%69 = load i64, i64* %8
%70 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %69)
br label %12
71: ; preds = %12
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [5 x i8] c"%d%d\00"
@.str.2 = [6 x i8] c"%lld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [100001 x [2 x i32]]
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast [100001 x [2 x i32]]* %4 to i8*
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = add nsw i32 %10, -1
store i32 %11, i32* %1
%12 = icmp eq i32 %10, 0
br i1 %12, label %52, label %13
13: ; preds = %0, %46
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32* %2, i32* %3)
%15 = load i32, i32* %2
%16 = icmp sgt i32 %15, 0
br i1 %16, label %19, label %46
17: ; preds = %19
%18 = icmp sgt i32 %24, 0
br i1 %18, label %27, label %46
19: ; preds = %13, %19
%20 = phi i64 [ %23, %19 ], [ 0, %13 ]
%21 = getelementptr inbounds [100001 x [2 x i32]], [100001 x [2 x i32]]* %4, i64 0, i64 %20, i64 0
%22 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %21)
%23 = add nuw nsw i64 %20, 1
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %19, label %17
27: ; preds = %17, %27
%28 = phi i64 [ %42, %27 ], [ 0, %17 ]
%29 = phi i64 [ %41, %27 ], [ 1, %17 ]
%30 = getelementptr inbounds [100001 x [2 x i32]], [100001 x [2 x i32]]* %4, i64 0, i64 %28, i64 1
%31 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %30)
%32 = load i32, i32* %3
%33 = getelementptr inbounds [100001 x [2 x i32]], [100001 x [2 x i32]]* %4, i64 0, i64 %28, i64 0
%34 = load i32, i32* %33
%35 = sdiv i32 %32, %34
%36 = sext i32 %35 to i64
%37 = load i32, i32* %30
%38 = sext i32 %37 to i64
%39 = mul nsw i64 %38, %36
%40 = icmp ult i64 %29, %39
%41 = select i1 %40, i64 %39, i64 %29
%42 = add nuw nsw i64 %28, 1
%43 = load i32, i32* %2
%44 = sext i32 %43 to i64
%45 = icmp slt i64 %42, %44
br i1 %45, label %27, label %46
46: ; preds = %27, %13, %17
%47 = phi i64 [ 1, %17 ], [ 1, %13 ], [ %41, %27 ]
%48 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %47)
%49 = load i32, i32* %1
%50 = add nsw i32 %49, -1
store i32 %50, i32* %1
%51 = icmp eq i32 %49, 0
br i1 %51, label %52, label %13
52: ; preds = %46, %0
ret i32 0
}