func main() var t: int :: cui@inputInt() for(1, t) var ss: [][]char :: cui@input().split(" ") var A: int :: cui@inputInt() var B: int :: cui@inputInt() var C: int :: cui@inputInt() var x: int :: cui@inputInt() var y: int :: cui@inputInt() var z: int :: cui@inputInt() ; bが最大のとき var ans1: int :: -1 block var a: int :: A var b: int :: B var c: int :: C 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 :: A var b: int :: B var c: int :: C 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