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:  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);  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. 


-----Example-----
Input
3
3 4 5
1 0 5
5 3 2

Output
9
0
6



-----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$.

Difficulty: interview

Starter code:

Solutions:
# Contest: Codeforces Round #593 (Div. 2) (https://codeforces.com/contest/1236)
# Problem: A: Stones (https://codeforces.com/contest/1236/problem/A)

def rint():
    return int(input())


def rints():
    return list(map(int, input().split()))


t = rint()
for _ in range(t):
    a, b, c, = rints()
    mx = 0
    for ta in range(0, min(a, b // 2) + 1):
        mx = max(mx, 3 * ta + 3 * min(b - 2 * ta, c // 2))
    print(mx)


for _ in range(int(input())):
    a,b,c=map(int,input().split())
    answer=0
    x=min(b,c//2)
    answer+=3*x
    b-=x
    x=min(a,b//2)
    answer+=3*x
    print(answer)

from sys import stdin
n=int(stdin.readline().strip())
for i in range(n):
    a,b,c=list(map(int,stdin.readline().strip().split()))
    ans=0
    while c>=2 and b>=1:
        c-=2
        b-=1
        ans+=3
    while b>=2 and a>=1:
        b-=2
        a-=1
        ans+=3
    print(ans)


for _ in range(int(input())):
    a, b, c = list(map(int, input().split()))
    ans = 0
    ans += min(b, c//2)*3
    b-=min(b, c//2)
    ans+=min(a, b//2)*3
    print(ans)

import sys
input = sys.stdin.readline

t=int(input())

for testcases in range(t):
    a,b,c=list(map(int,input().split()))
    ANS=0

    ANS+=min(b,c//2)
    b-=ANS
    ANS+=min(a,b//2)
    print(ANS*3)

    


for _ in range(int(input())):
    x,y,z=list(map(int,input().split()))
    m = 0
    for a in range(x + 1):
        b = min(z // 2, y - 2 * a)
        m = max(m, 3 * (a + b))
    print (m)


q = int(input())
for fwefe in range(q):
	wyn = 0
	a,b,c = list(map(int,input().split()))
	while b > 0 and c > 1:
		b -= 1
		c -= 2
		wyn += 3
	while a > 0 and b > 1:
		a -= 1
		b -= 2
		wyn += 3
	print(wyn)

n = int(input())
for i in range(n):
    a, b, c = map(int, input().split())
    ss = min(c // 2, b)
    b -= ss
    tt = min(b // 2, a)
    print((ss + tt) * 3)

t = int(input())
for y in range(t):
	a,b,c = map(int,input().split())
	ct = 0
	ct += min(b,c//2)
	b -= ct
	ct += min(a,b//2)
	print(ct*3)

for TT in range(1, int(input()) + 1):
    a, b, c = map(int, input().split())
    res = 0
    for x in range(min(a, b // 2) + 1):
        y = min(b - 2 * x, c // 2)
        res = max(res, 3 * (x + y))
    print(res)

t = int(input())
for _ in range(t):
    a, b, c = map(int, input().split())
    ans = 0
    
    cnt_2 = min(c // 2, b)
    ans += cnt_2 * 3
    b -= cnt_2
    c -= cnt_2*2
    
    cnt_1 = min(a, b // 2)
    ans += cnt_1 * 3
    print(ans) 

for _ in range(int(input())):
    a, b, c = list(map(int, input().split()))
    c2 = min(c // 2, b)
    print((c2 + min((b - c2) // 2, a)) * 3)


t = int(input())
for i in range(t):
    a,b,c = map(int,input().split())
    ans = min(b,c//2)
    b-=ans
    print(3*(ans+min(a,b//2)))

t = int(input())
for i in range(t):
    a, b, c = map(int, input().split())
    ans = 0
    while b >= 1 and c >= 2:
        ans += 3
        b -= 1
        c -= 2
    while b >= 2 and a >= 1:
        ans += 3
        b -= 2
        a -= 1
    print(ans)

t=int(input())
for i in range(t):
    g=[int(x) for x in input().split()]
    h=min(g[1],int(g[2]/2))
    j=min(g[0],int((g[1]-h)/2))
    print(3*(h+j))


''' CODED WITH LOVE BY SATYAM KUMAR '''

from sys import stdin, stdout
import heapq
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
import sys

sys.setrecursionlimit(10 ** 6)  # max depth of recursion
threading.stack_size(2 ** 27)  # new thread will get stack of such size
fac_warm_up = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7


class MergeFind:
    def __init__(self, n):
        self.parent = list(range(n))
        self.size = [1] * n
        self.num_sets = n
        self.lista = [[_] for _ in range(n)]

    def find(self, a):
        to_update = []
        while a != self.parent[a]:
            to_update.append(a)
            a = self.parent[a]
        for b in to_update:
            self.parent[b] = a
        return self.parent[a]

    def merge(self, a, b):
        a = self.find(a)
        b = self.find(b)
        if a == b:
            return
        if self.size[a] < self.size[b]:
            a, b = b, a
        self.num_sets -= 1
        self.parent[b] = a
        self.size[a] += self.size[b]
        self.lista[a] += self.lista[b]

    def set_size(self, a):
        return self.size[self.find(a)]

    def __len__(self):
        return self.num_sets


def display(string_to_print):
    stdout.write(str(string_to_print) + "\n")


def prime_factors(n):  # n**0.5 complex
    factors = dict()
    for i in range(2, math.ceil(math.sqrt(n)) + 1):
        while n % i == 0:
            if i in factors:
                factors[i] += 1
            else:
                factors[i] = 1
            n = n // i
    if n > 2:
        factors[n] = 1
    return (factors)


def all_factors(n):
    return set(reduce(list.__add__,
                      ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))


def fibonacci_modP(n, MOD):
    if n < 2: return 1
    return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(
        fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD


def factorial_modP_Wilson(n, p):
    if (p <= n):
        return 0
    res = (p - 1)
    for i in range(n + 1, p):
        res = (res * cached_fn(InverseEuler, i, p)) % p
    return res


def binary(n, digits=20):
    b = bin(n)[2:]
    b = '0' * (digits - len(b)) + b
    return b


def is_prime(n):
    """Returns True if n is prime."""
    if n < 4:
        return True
    if n % 2 == 0:
        return False
    if n % 3 == 0:
        return False
    i = 5
    w = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += w
        w = 6 - w
    return True


def generate_primes(n):
    prime = [True for i in range(n + 1)]
    p = 2
    while p * p <= n:
        if prime[p]:
            for i in range(p * 2, n + 1, p):
                prime[i] = False
        p += 1
    return prime


factorial_modP = []


def warm_up_fac(MOD):
    nonlocal factorial_modP, fac_warm_up
    if fac_warm_up: return
    factorial_modP = [1 for _ in range(fac_warm_up_size + 1)]
    for i in range(2, fac_warm_up_size):
        factorial_modP[i] = (factorial_modP[i - 1] * i) % MOD
    fac_warm_up = True


def InverseEuler(n, MOD):
    return pow(n, MOD - 2, MOD)


def nCr(n, r, MOD):
    nonlocal fac_warm_up, factorial_modP
    if not fac_warm_up:
        warm_up_fac(MOD)
        fac_warm_up = True
    return (factorial_modP[n] * (
            (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD)) % MOD)) % MOD


def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return list(map(int, stdin.readline().split()))


def get_list():
    return list(map(int, stdin.readline().split()))


memory = dict()


def clear_cache():
    nonlocal memory
    memory = dict()


def cached_fn(fn, *args):
    nonlocal memory
    if args in memory:
        return memory[args]
    else:
        result = fn(*args)
        memory[args] = result
        return result


def ncr(n, r):
    return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))


def binary_search(i, li):
    fn = lambda x: li[x] - x // i
    x = -1
    b = len(li)
    while b >= 1:
        while b + x < len(li) and fn(b + x) > 0:  # Change this condition 2 to whatever you like
            x += b
        b = b // 2
    return x


# -------------------------------------------------------------- MAIN PROGRAM


TestCases = True
optimise_for_recursion = True  # Can not be used clubbed with TestCases WHen using recursive functions, use Python 3


def main():
    x, y, z = get_tuple()
    res = min(y, z//2)
    y -= res
    res += min(x, y//2)
    print(res*3)

# --------------------------------------------------------------------- END=


if TestCases:
    for i in range(get_int()):
        main()
else:
    main() if not optimise_for_recursion else threading.Thread(target=main).start()


t = int(input())
for query in range(t):
  a, b, c = list(map(int, input().split()))
  ans = 0
  for cnt1 in range(101):
    for cnt2 in range(101):
      if a >= cnt1 and b >= cnt1 * 2 + cnt2 and c >= cnt2 * 2:
        ans = max(ans, cnt1 * 3 + cnt2 * 3)
  print(ans)


def f1(a, b, c):
    res = 0
    d= min(b, c // 2)
    res += 3 * d
    b -= d
    res += min(a, b // 2) * 3
    return res

def f2(a, b, c):
    res = 0
    d = min(a, b // 2)
    res += 3 * d
    b -= 2 * d
    res += min(b, c // 2) * 3
    return res


t = int(input())
for i in range(t):
    a, b, c = list(map(int, input().split()))
    print(max(f1(a, b, c), f2(a, b, c)))


import sys
readline = sys.stdin.readline

N = int(readline())

Ans = [None]*N
for qu in range(N):
    A, B, C = map(int, readline().split())
    res = 0
    for a in range(A+1):
        if 2*a > B:
            break
        cnt = 3*a
        t = B - 2*a
        t = min(t, C//2)
        cnt += 3*t
        res = max(res, cnt)
    Ans[qu] = res

print('\n'.join(map(str, Ans)))

t=int(input())
for i in range(t):
    a,b,c=map(int,input().split())
    ans1=min(a,b//2)
    b1=b-ans1*2
    ans1+=min(b1,c//2)
    ans2=min(b,c//2)
    b-=ans2
    ans2+=min(a,b//2)
    print(max(ans1*3,ans2*3))

t = int(input())

for i in range(t):
    a, b, c = list(map(int, input().split()))
    ans = 0
    for t1 in range(a + 1):
        for t2 in range(b + 1):
            if a - t1 >= 0 and b - 2 * t1 - t2 >= 0 and c - 2 * t2 >= 0:
                ans = max(ans, 3 * (t1 + t2))
    print(ans)

import sys
import math
from collections import defaultdict
from itertools import combinations
from itertools import permutations
input = lambda : sys.stdin.readline().rstrip()
read = lambda : list(map(int, input().split()))
def write(*args, sep="\n"):
  for i in args:
    sys.stdout.write("{}".format(i) + sep)
INF = float('inf')
MOD = int(1e9 + 7)

for _ in range(int(input())):
  a, b, c = read()
  x = min(b, c // 2)
  b -= x 
  y = min(a, b // 2)

  print(3 * x + 3 * y)


t = int(input())
for i in range(t):
	a, b, c = map(int, input().split())
	if b == 0:
		print(0)
	else:
		res = 0
		res += 3 * min(b, c // 2)
		b -= res // 3
		res += 3 * min(a, b // 2)
		print(res)