Codeforces Round 593 (Div. 2)
A
Stones
Codeforces
800
原题
←B →
翻译中…

Alice is playing with some stones.

翻译中…

Now there are three numbered heaps of stones. The first of them contains $a$ stones, the second of them contains $b$ stones and the third of them contains $c$ stones.

翻译中…

Each time she can do one of two operations:

翻译中…
  1. take one stone from the first heap and two stones from the second heap (this operation can be done only if the first heap contains at least one stone and the second heap contains at least two stones);
  2. take one stone from the second heap and two stones from the third heap (this operation can be done only if the second heap contains at least one stone and the third heap contains at least two stones).
翻译中…

She wants to get the maximum number of stones, but she doesn't know what to do. Initially, she has $0$ stones. Can you help her?

翻译中…

Input

翻译中…

The first line contains one integer $t$ ($1 \leq t \leq 100$)  — the number of test cases. Next $t$ lines describe test cases in the following format:

翻译中…

Line contains three non-negative integers $a$, $b$ and $c$, separated by spaces ($0 \leq a,b,c \leq 100$) — the number of stones in the first, the second and the third heap, respectively.

翻译中…

In hacks it is allowed to use only one test case in the input, so $t = 1$ should be satisfied.

翻译中…

Output

翻译中…

Print $t$ lines, the answers to the test cases in the same order as in the input. The answer to the test case is the integer  — the maximum possible number of stones that Alice can take after making some operations.

翻译中…

Note

翻译中…

For the first test case in the first test, Alice can take two stones from the second heap and four stones from the third heap, making the second operation two times. Then she can take one stone from the first heap and two stones from the second heap, making the first operation one time. The summary number of stones, that Alice will take is $9$. It is impossible to make some operations to take more than $9$ stones, so the answer is $9$.

翻译中…

样例

Input #1
3
3 4 5
1 0 5
5 3 2
Output #1
9
0
6
InputCopy OutputCopy
题目信息
题号
1236A
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。