روز
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
روز
ساعت
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
ساعت
دقیقه
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
دقیقه
ثانیه
۹۰۱۲۳۴۵۶۷۸۹۰۹۰۱۲۳۴۵۶۷۸۹۰
ثانیه
  • محدودیت زمان: ۱ ثانیه
  • محدودیت حافظه: ۲۵۶ مگابایت

Amin and Niloufar are playing Rock-Paper-Scissors together. They are not kids, so instead of playing with their hands, they use actual rocks, papers, and scissors.

Amin has RaR_a rocks, PaP_a papers, and SaS_a scissors. Similarly, Niloufar has RnR_n rocks, PnP_n papers, and SnS_n scissors.

توضیح تصویر

In each round of the game, both players use one of their rocks, papers, or scissors (if a player has no items left, they'll lose that round). According to the traditional rules of this game, paper beats rock, scissors beat paper, and rock beats scissors. If both items are the same, the round is a draw.

Each win earns 33 points, draw earns 11 point, and lose earns no points. Your task is to write a program to calculate the maximum score that Amin can achieve among all possible outcomes.

ورودی

The first line of input contains an integer tt, representing the number of test cases.

1t1051 \leq t \leq 10^5

In the first line of each test case, three integers RaR_a, PaP_a, and SaS_a are given. In the second line of each test case, three integers RnR_n, PnP_n, and SnS_n are given.

0Ra,Pa,Sa,Rn,Pn,Sn1090 \leq R_a, P_a, S_a, R_n, P_n, S_n \leq 10^9

خروجی

For each test case, print a single integer representing the maximum score Amin can achieve.

مثال‌ها

ورودی نمونه ۱

3
1 1 1
1 1 1
3 0 2
0 3 1
8 0 0
8 0 0
Plain text

خروجی نمونه ۱

9
12
8
Plain text

ارسال پاسخ برای این سؤال
فایلی انتخاب نشده است.