func main() var T: int :: cui@input().toInt(&) for t(1, T) var ss: [][]char :: cui@input().split(" ") var AA: int :: ss[0].toInt(&) var BB: int :: ss[1].toInt(&) var CC: int :: ss[2].toInt(&) var x: int :: ss[3].toInt(&) var y: int :: ss[4].toInt(&) var z: int :: ss[5].toInt(&) ; Bが最大のとき var ans1: int :: -1 block var A: int :: AA var B: int :: BB var C: int :: CC var cnt: int :: 0 if(A >= B) do cnt :+ (A - (B - 1)) * x do A :: B - 1 end if if(C >= B) do cnt :+ (C - (B - 1)) * z do C :: B - 1 end if if(A = C) do cnt :+ lib@min(x, z) do A :- 1 end if if(A > 0 & C > 0) do ans1 :: cnt end if end block ; Bが最小のとき var ans2: int :: -1 block var A: int :: AA var B: int :: BB var C: int :: CC var cnt: int :: 0 if(A = C) do cnt :+ lib@min(x, z) do A :- 1 end if var target: int :: lib@min(A, C) if(B >= target) do cnt :+ (B - (target - 1)) * y do B :: target - 1 end if if(B > 0) do ans2 :: cnt end if end block var ans: int :: -1 if(ans1 >= 0) do ans :: ans1 end if if(ans2 >= 0) if(ans > 0) do ans :: lib@min(ans, ans2) else do ans :: ans2 end if end if do cui@print("\{ans}\n") end for end func