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: EASY
Tags: Complete search

Mathematics

Greedy algorithms
Skill types: Complete search

Greedy algorithms

Starter code:

Solutions:
n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	ans = 0
	c_1 = c // 2
	if b <= c_1:
		print(3 * b)
	else:
		b = b - c_1
		b_1 = b // 2
		if a <= b_1:
			print((a + c_1) * 3)
		else:
			print((b_1 + c_1) * 3)


t = int(input())
while t != 0:
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	m = a + b + c
	z = 0
	while b > 0 and c > 1:
		b = b - 1
		c = c - 2
		z += 3
	while a > 0 and b > 1:
		a = a - 1
		b = b - 2
		z += 3
	print(z)
	t -= 1


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


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

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

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(a, b, c) = In()
		ans = 0
		t = min(b, c // 2)
		b -= t
		ans += 3 * t
		t = min(a, b // 2)
		ans += 3 * t
		print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


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


t = int(input())
for i in range(0, t):
	s = input()
	s = s.split(' ')
	a = int(s[0])
	b = int(s[1])
	c = int(s[2])
	g = 0
	while c > 1 and b >= 1:
		c = c - 2
		b = b - 1
		g = g + 3
	while b > 1 and a >= 1:
		b = b - 2
		a = a - 1
		g = g + 3
	print(g)


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)


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


for _ in range(int(input())):
	(a, b, c) = [int(z) for z in input().split()]
	ans = 0
	if b == 0:
		print(0)
	else:
		while c >= 2 and b > 0:
			ans += 3
			b -= 1
			c -= 2
		while b >= 2 and a > 0:
			ans += 3
			b -= 2
			a -= 1
		print(ans)


length = int(input())
for i in range(0, length):
	stones = 0
	splice = input().split(' ')
	a = int(splice[0])
	b = int(splice[1])
	c = int(splice[2])
	aa = min(b, int(c / 2))
	b -= aa
	c -= aa * 2
	stones += aa * 3
	aa = min(a, int(b / 2))
	stones += aa * 3
	print(stones)


from sys import stdin
t = int(stdin.readline().rstrip())
for _ in range(t):
	(a, b, c) = [int(x) for x in stdin.readline().rstrip().split()]
	tmp1 = min(a, b // 2)
	ans1 = tmp1 * 3 + min(c // 2, b - tmp1 * 2) * 3
	tmp2 = min(b, c // 2)
	ans2 = tmp2 * 3 + min(a, (b - tmp2) // 2) * 3
	print(max(ans1, ans2))


import os, sys
t = int(sys.stdin.readline().strip())
for _ in range(t):
	(a, b, c) = map(int, sys.stdin.readline().strip().split())
	anz2 = min(b, c // 2)
	anz1 = min(a, (b - anz2) // 2)
	print(3 * (anz1 + anz2))


def main():
	T = int(input())
	for _ in range(T):
		(A, B, C) = map(int, input().split())
		y = min(B, C // 2)
		B -= y
		C -= 2 * y
		x = min(A, B // 2)
		print(3 * (x + y))
main()


for u in range(int(input())):
	(x, y, z) = map(int, input().split())
	c = 0
	while z >= 2 and y >= 1:
		y = y - 1
		z = z - 2
		c = c + 3
	while y >= 2 and x >= 1:
		y = y - 2
		x = x - 1
		c = c + 3
	print(c)


def Stones_2():
	T = int(input())
	for x in range(T):
		(A, B, C) = map(int, input().split())
		S = 0
		while B > 0 and C > 1:
			B -= 1
			C -= 2
			S += 3
		while A > 0 and B > 1:
			A -= 1
			B -= 2
			S += 3
		print(S)
Stones_2()


import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations

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

def num():
	return map(int, sys.stdin.readline().split())

def nu():
	return int(input())

def find_gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	gg = find_gcd(x, y)
	return x * y // gg

def fox(a, b):
	xp = b // 2
	ox = min(xp, a)
	oz = a - ox
	oi = b - ox * 2
	return (oz, oi, ox * 3)

def solve():
	t = nu()
	for tt in range(t):
		(a, b, c) = num()
		kl = fox(a, b)
		oi = fox(kl[1], c)
		oz = fox(b, c)
		op = fox(a, oz[0])
		print(max(op[2] + oz[2], kl[2] + oi[2]))
solve()


n = int(input())
for i in range(n):
	(a, b, c) = [int(x) for x in input().split()]
	q1 = 0
	q2 = 0
	q1 = min(a, int(b / 2)) * 3
	a2 = a - min(a, int(b / 2))
	b2 = b - 2 * min(a, int(b / 2))
	q1 = q1 + min(b2, int(c / 2)) * 3
	q2 = min(b, int(c / 2)) * 3
	b3 = b - min(b, int(c / 2))
	c3 = c - 2 * min(b, int(c / 2))
	q2 = q2 + min(a, int(b3 / 2)) * 3
	if q1 > q2:
		print(q1)
	else:
		print(q2)


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


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


t = int(input())
for i in range(t):
	(a, b, c) = [int(x) for x in input().split()]
	step1 = min(c // 2, b)
	max_rocks = 3 * (step1 + min((b - step1) // 2, a))
	print(max_rocks)


t = int(input())
for t_ in range(t):
	(a, b, c) = [int(x) for x in input().split()]
	count = 0
	while b >= 1 and c >= 2:
		b -= 1
		c -= 2
		count += 3
	while a >= 1 and b >= 2:
		a -= 1
		b -= 2
		count += 3
	print(count)


t = int(input())
if 1 <= t <= 100:
	for i in range(t):
		(a, b, c) = input().split()
		a = int(a)
		b = int(b)
		c = int(c)
		if c >= 2 * b:
			k = 3 * b
			if k >= 3:
				print(k)
			else:
				print(0)
		else:
			k = c // 2 * 3
			j = b - k / 3
			if j >= 2 * a:
				l = 3 * a
				z = k + l
				z = int(z)
				if z >= 3:
					print(z)
				else:
					print(0)
			else:
				l = j // 2 * 3
				z = k + l
				z = int(z)
				if z >= 3:
					print(z)
				else:
					print(0)


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


t = int(input())
for _ in range(t):
	pedras = 0
	(h1, h2, h3) = list(map(int, input().split()))
	num_op2 = min(h2, h3 // 2)
	h2 -= num_op2
	num_op1 = min(h1, h2 // 2)
	print((num_op2 + num_op1) * 3)


import itertools

def main():
	n = int(input())
	for i in range(n):
		(a, b, c) = [int(v) for v in input().split()]
		c1 = min(b, c // 2)
		c11 = min(a, (b - c1) // 2)
		r1 = c1 * 3 + c11 * 3
		c2 = min(a, b // 2)
		c21 = min(c // 2, b - c2 * 2)
		r2 = c2 * 3 + c21 * 3
		print(max(r1, r2))
main()


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


def scanf():
	_input = input().split(' ')
	res = []
	for elem in _input:
		res.append(int(elem))
	return res
for _ in range(int(input())):
	Stones = 0
	Vars = scanf()
	while Vars[1] > 0 and Vars[2] > 1:
		Stones += 3
		Vars[1] -= 1
		Vars[2] -= 2
	while Vars[0] > 0 and Vars[1] > 1:
		Stones += 3
		Vars[0] -= 1
		Vars[1] -= 2
	print(Stones)


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


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


t = int(input())
answers = list()
l = 0
while l < t:
	heaps = input()
	heaps = heaps.split()
	i = 0
	while i < 3:
		heaps[i] = int(heaps[i])
		i = i + 1
	result1 = 0
	result2 = 0
	if int(heaps[1] / 2) >= heaps[0]:
		result1 = result1 + int(heaps[0]) * 3
		remain_heap_2 = heaps[1] - int(heaps[0] * 2)
		remain_heap_3 = heaps[2]
		while remain_heap_2 >= 1 and remain_heap_3 >= 2:
			result1 = result1 + 3
			remain_heap_2 = remain_heap_2 - 1
			remain_heap_3 = remain_heap_3 - 2
	else:
		result1 = result1 + int(heaps[1] / 2) * 3
		if heaps[1] / 2 % 1 != 0 and heaps[2] >= 2:
			result1 = result1 + 3
	if int(heaps[2] / 2) >= heaps[1]:
		result2 = heaps[1] * 3
	else:
		result2 = 3 * int(heaps[2] / 2)
		remain_heap_2 = heaps[1] - int(heaps[2] / 2)
		remain_heap_1 = heaps[0]
		while remain_heap_1 >= 1 and remain_heap_2 >= 2:
			result2 = result2 + 3
			remain_heap_1 = remain_heap_1 - 1
			remain_heap_2 = remain_heap_2 - 2
	if result1 >= result2:
		answers.append(result1)
	else:
		answers.append(result2)
	l = l + 1
l = 0
while l < t:
	print(answers[l])
	l = l + 1


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


def program():
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	li = []
	for i in range(a + 1):
		for j in range(c // 2 + 1):
			if 2 * i + j <= b:
				li.append(3 * i + 3 * j)
	print(max(li))
t = int(input())
for x in range(t):
	program()


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	x = 0
	while b >= 2 and a >= 1 or (c >= 2 and b >= 1):
		if min(c // 2, b) > min(b // 2, a):
			c -= 2
			b -= 1
		else:
			b -= 2
			a -= 1
		x += 3
	print(x)


number = input()
counter = 0
array = []
for i in range(int(number)):
	(x, y, z) = input().split()
	while int(y) > 0 and int(z) >= 2:
		y = int(y) - 1
		z = int(z) - 2
		counter = counter + 3
	while int(x) > 0 and int(y) >= 2:
		x = int(x) - 1
		y = int(y) - 2
		counter = counter + 3
	array.append(counter)
	counter = 0
for i in range(int(number)):
	print(array[i])


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


n = int(input())
for i in range(n):
	(a, b, c) = [int(i) for i in input().split()]
	sum = 0
	e = b // 1
	f = c // 2
	b = b - min(e, f)
	c = c - min(e, f)
	sum = sum + 3 * min(e, f)
	sum = sum + 3 * min(a // 1, b // 2)
	print(sum)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	res = 0
	while True:
		if b >= 1 and c >= 2:
			res += 3
			c -= 2
			b -= 1
		elif a >= 1 and b >= 2:
			res += 3
			a -= 1
			b -= 2
		else:
			print(res)
			break


n = int(input())
a = [0] * n
b = [0] * n
c = [0] * n
for i in range(n):
	(a[i], b[i], c[i]) = map(int, input().split())
	ans = 0
	flag = True
	while flag:
		flag = False
		if c[i] > 1 and b[i] > 0:
			c[i] -= 2
			b[i] -= 1
			ans += 3
			flag = True
		elif a[i] > 0 and b[i] > 1:
			b[i] -= 2
			a[i] -= 1
			ans += 3
			flag = True
	print(ans)


import sys
from math import *

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())
for t in range(mint()):
	(a, b, c) = mints()
	e = min(a, b // 2)
	f = min(b, c // 2)
	g = min(b - e * 2, c // 2)
	h = min(a, (b - f) // 2)
	print(max(e + g, f + h) * 3)


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


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


def stones(n):
	(a, b, c) = (n[0], n[1], n[2])
	st = 0
	if c // 2 <= b:
		st += c // 2 * 2 + c // 2
		b -= c // 2
		c -= c // 2 * 2
	else:
		st += b * 2 + b
		b = 0
	if b // 2 <= a:
		st += b // 2 * 2 + b // 2
		a -= b // 2
		b -= b // 2 * 2
	else:
		st += a * 2 + a
		a = 0
	return st
tc = int(input())
for i in range(tc):
	n = list(map(int, input().split()))
	print(stones(n))


import sys
import collections
input = sys.stdin.readline

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

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

def rintas():
	return [int(i) for i in input().strip().split()]

def gcd(a, b):
	if a == 0:
		return b
	return gcd(a % b, a)
n = rint()
for _ in range(n):
	(a, b, c) = rints()
	ans = 0
	while a > 0 and b > 1 or (b > 0 and c > 1):
		if b > 0 and c > 1:
			ans += 3
			b -= 1
			c -= 2
		elif a > 0 and b > 1:
			ans += 3
			a -= 1
			b -= 2
		else:
			break
	print(ans)


n = int(input())
for _ in range(n):
	(a, b, c) = map(int, input().split())
	(a1, b1, c1) = (a, b, c)
	(a2, b2, c2) = (a, b, c)
	(F, S) = (0, 0)
	while b1:
		if b1 >= 1 and c1 >= 2:
			F += 3
			b1 -= 1
			c1 -= 2
		elif a1 >= 1 and b1 >= 2:
			F += 3
			a1 -= 1
			b1 -= 2
		else:
			break
	while b2:
		if b2 > 0 and c2 >= 2:
			S += 3
			b2 -= 1
			c2 -= 2
		elif a2 > 0 and b2 >= 2:
			S += 3
			a2 -= 1
			b2 -= 2
		else:
			break
	print(max(F, S))


import sys
input = sys.stdin.readline
t = int(input())
for testcases in range(t):
	(a, b, c) = 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())):
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	count = 0
	while c >= 2 and b >= 1:
		count += 3
		c = c - 2
		b = b - 1
	while b >= 2 and a >= 1:
		count += 3
		b = b - 2
		a = a - 1
	print(count)


import sys
from math import ceil
cin = sys.stdin.buffer.readline
for _ in range(int(cin())):
	(a, b, c) = map(int, cin().split())
	print(3 * min(b, c // 2) + 3 * min(a, max(0, b - c // 2) // 2))


import sys
sys.setrecursionlimit(pow(10, 9))
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	mn = min(c // 2, b)
	res = 3 * mn
	b -= mn
	mn = min(a, b // 2)
	res += 3 * mn
	print(res)


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


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	ABC = [tuple(map(int, input().split())) for _ in [0] * T]
	for (a, b, c) in ABC:
		(divb, modb) = divmod(b, 2)
		case1 = min(a, divb)
		(divc, modc) = divmod(c, 2)
		case1 += min(modb, divc)
		(divc, modc) = divmod(c, 2)
		case2 = min(b, divc)
		(divb, modb) = divmod(b - case2, 2)
		case2 += min(a, divb)
		print(max(case1 * 3, case2 * 3))
main()


t = int(input())
for u in range(t):
	(a, b, c) = map(int, input().split())
	b1 = 0
	mx = 0
	for i in range(a + 1):
		ans = 0
		if i * 2 > b:
			break
		ans = i * 3
		b1 = b - 2 * i
		ans += min(b1, c // 2) * 3
		mx = max(ans, mx)
	print(mx)


cases = int(input())

def op1(lista, izq, der):
	recolected = 0
	while lista[izq] >= 1 and lista[der] >= 2:
		recolected += 1
		lista[izq] -= 1
		lista[der] -= 2
	return recolected
for i in range(cases):
	stones = list(map(int, input().split()))
	major = stones[1:]
	menor = min(major)
	menor = stones.index(menor)
	major = max(major)
	major = stones.index(major)
	counter = op1(stones, 1, 2)
	counter += op1(stones, 0, 1)
	if op1(stones, 0, 1) + op1(stones, 1, 2) > counter:
		counter = op1(stones, 0, 1) + op1(stones, 1, 2)
	print(counter * 3)


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


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(a, b, c) = list(map(int, input().split()))
	maxi = 0
	for x in range(a + 1):
		for y in range(c // 2 + 1):
			if 2 * x + y <= b and 3 * x + 3 * y > maxi:
				maxi = 3 * x + 3 * y
	print(maxi)


t = int(input())
ti = []
for i in range(0, t):
	a = input()
	z = [int(j) for j in a.split()]
	ti.append(z)
a = len(ti)

def total_stones(a, b, c):
	total = 0
	while a > 0 and b > 1 or (b > 0 and c > 1):
		z = max(b, c)
		if z == b:
			if a == 0 and c != 0:
				b = b - 1
				c = c - 2
				total = total + 3
			else:
				a = a - 1
				b = b - 2
				total = total + 3
		elif z == c and c != 0 and (b != 0):
			b = b - 1
			c = c - 2
			total = total + 3
		elif b == c:
			b = b - 1
			c = c - 2
			total = total + 3
	return total
for i in range(0, a):
	l = [int(i) for i in ti[i]]
	a = l[0]
	b = l[1]
	c = l[2]
	print(total_stones(a, b, c))


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


import sys
import math
input = sys.stdin.readline
T = int(input())
for i in range(0, T):
	(a, b, c) = map(int, input().split())
	ans1 = min(a, b // 2)
	ans1 += min(b - 2 * ans1, c // 2)
	ans2 = min(b, c // 2)
	ans2 += min(a, (b - ans2) // 2)
	print(3 * ans2)


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


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	x = c // 2
	if b <= x:
		print(b * 3)
	else:
		y = (b - x) // 2
		if a <= y:
			print(a * 3 + x * 3)
		else:
			print(y * 3 + x * 3)


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


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	best = 0
	for i in range(min(a, b // 2) + 1):
		now_ans = i * 3 + min(b - 2 * i, c // 2) * 3
		if now_ans > best:
			best = now_ans
	print(best)


import sys
input = sys.stdin.readline

def r1():
	return int(input())

def rm():
	return map(int, input().split())
t = r1()
for i in range(t):
	(a, b, c) = rm()
	x = min(b, c // 2)
	r = 3 * x
	b -= x
	x = min(a, b // 2)
	r += 3 * x
	print(r)


tes = int(input())
for i in range(0, tes):
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	ans = 0
	if c // 2 > b:
		ans = ans + b + 2 * b
	else:
		ans = ans + c // 2 * 2 + c // 2
		b = b - c // 2
		if b // 2 < a:
			ans = ans + b // 2 * 3
		else:
			ans = ans + 2 * a + a
	print(ans)


from collections import defaultdict as dc
import sys
import math
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if b == 0:
		print(0)
	else:
		x = 0
		p = c // 2
		if p <= b:
			x += p + 2 * p
			b -= p
		else:
			x += b + 2 * b
			b = 0
		q = b // 2
		if q <= a:
			x += q + 2 * q
			a -= q
		else:
			x += a + 2 * a
		print(x)


for _ in range(int(input())):
	(a1, b1, c1) = list(map(int, input().split()))
	(ans1, ans2) = (0, 0)
	(a, b, c) = (a1, b1, c1)
	k = min(a, b // 2)
	a -= k
	b -= 2 * k
	ans1 += 3 * k
	k = min(b, c // 2)
	b -= k
	c -= 2 * k
	ans1 += 3 * k
	(a, b, c) = (a1, b1, c1)
	k = min(b, c // 2)
	b -= k
	c -= 2 * k
	ans2 += 3 * k
	k = min(a, b // 2)
	a -= k
	b -= 2 * k
	ans2 += 3 * k
	print(max(ans1, ans2))


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


import sys
n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	r = 0
	x1 = min(c // 2, b)
	b -= x1
	x2 = min(b // 2, a)
	print((x1 + x2) * 3)


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)


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


def fun(a, b, c, ans):
	global dp
	pos = a >= 1 and b >= 2 and (c >= 0) or (b >= 1 and c >= 2 and (a >= 0))
	if not pos:
		return ans
	else:
		if (a, b, c) in dp:
			return dp[a, b, c]
		temp = ans
		if a - 1 >= 0 and b - 2 >= 0:
			temp = fun(a - 1, b - 2, c, ans + 3)
		if b - 1 >= 0 and c - 2 >= 0:
			temp = max(fun(a, b - 1, c - 2, ans + 3), temp)
		dp[a, b, c] = temp
		return temp
for t in range(int(input())):
	dp = dict()
	(a, b, c) = [int(j) for j in input().split()]
	print(fun(a, b, c, 0))


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


from math import *
t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = map(int, input().split())
	(a1, b1, c1) = (a, b, c)
	x = min(a, b // 2)
	x_ = min(2 * a, b // 2 * 2)
	a -= x
	b -= x_
	val = x + x_ + min(b, c // 2) + min(2 * b, c // 2 * 2)
	y = min(b1, c1 // 2)
	y_ = min(2 * b1, c1 // 2 * 2)
	b1 -= y
	c1 -= y_
	val1 = y + y_ + min(a1, b1 // 2) + min(2 * a1, b1 // 2 * 2)
	print(max(val, val1))


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


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	z1 = c // 2
	if b < z1:
		z1 = b
	z2 = (b - z1) // 2
	if z2 > a:
		z2 = a
	print((z1 + z2) * 3)


def ii():
	return int(input())

def mi():
	return map(int, input().split())
t = int(input())
while t:
	(a, b, c) = mi()
	k = c // 2
	if b <= k:
		print(3 * b)
	else:
		ans = 3 * k
		b -= k
		b = b // 2
		if a >= b:
			ans += 3 * b
		else:
			ans += 3 * a
		print(ans)
	t -= 1


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))


from os import path
import sys
import time
mod = int(1000000000.0 + 7)
from math import ceil, floor, gcd, log, log2, factorial, sqrt
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, accumulate, groupby, product
from bisect import *
from functools import reduce
from operator import mul

def star(x):
	return print(' '.join(map(str, x)))

def grid(r):
	return [lint() for i in range(r)]

def stpr(x):
	return sys.stdout.write(f'{x}' + '\n')
INF = float('inf')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import sys
from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil
from copy import deepcopy

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

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

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

def pr(n):
	return stdout.write(str(n) + '\n')

def solve():
	(a, b, c) = invr()
	(a1, b1, c1) = (a, b, c)
	res = 0
	res1 = 0
	while a > 0 and b > 1:
		res += 3
		a -= 1
		b -= 2
	while b > 0 and c > 1:
		res += 3
		b -= 1
		c -= 2
	while b1 > 0 and c1 > 1:
		res1 += 3
		b1 -= 1
		c1 -= 2
	while a1 > 0 and b1 > 1:
		res1 += 3
		a1 -= 1
		b1 -= 2
	print(max(res, res1))
t = 1
t = inp()
for _ in range(t):
	solve()


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)
from collections import *

def li():
	return [int(i) for i in input().rstrip('\n').split(' ')]

def val():
	return int(input().rstrip('\n'))

def st():
	return input().rstrip('\n')

def sttoli():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(a, b, c) = li()
	tot = 0
	while c >= 2 and b:
		c -= 2
		b -= 1
		tot += 3
	while b >= 2 and a:
		b -= 2
		a -= 1
		tot += 3
	print(tot)


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


k = int(input())
for _ in range(k):
	first_step = 0
	(a, b, c) = map(int, input().split())
	if (c > 1) & (b > 0):
		t = min(c // 2, b)
		first_step = 3 * t
		b = b - t
		z = min(b // 2, a)
		first_step += z * 3
		print(first_step)
	elif b == 0:
		print('0')
	elif c <= 1:
		k = min(a, b // 2)
		print(3 * k)


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


b = int(input())
a = []
for i in range(b):
	a.append([int(j) for j in input().split()])
for i in a:
	if int(i[2] / 2) >= i[1]:
		print(int(i[1] * 3))
	else:
		c = int(i[1] - int(i[2] / 2))
		if int(c / 2) <= i[0]:
			print(int(i[2] / 2) * 3 + int(c / 2) * 3)
		else:
			print(int(i[2] / 2) * 3 + i[0] * 3)


def solve():
	pass

def main():
	t = int(input())
	for i in range(t):
		ans = 0
		(a, b, c) = map(int, input().split())
		while True:
			if c < b and b >= 2 and (a >= 1):
				ans += 3
				b -= 2
				a -= 1
			elif c >= 2 and b >= 1:
				ans += 3
				b -= 1
				c -= 2
			else:
				print(ans)
				break
main()


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


t = int(input())
for test in range(t):
	(a1, b1, c1) = map(int, input().split(' '))
	res = 0
	res1 = min(a1, b1 // 2)
	a = a1 - res1
	b = b1 - res1 * 2
	res2 = min(b, c1 // 2)
	res = res1 * 3 + res2 * 3
	res1 = min(b1, c1 // 2)
	b1 -= res1
	res2 = min(a1, b1 // 2)
	res = max(res, res1 * 3 + res2 * 3)
	print(res)


t = int(input())
for tc in range(t):
	(a, b, c) = map(int, input().split())
	max1 = 0
	max2 = 0
	(a2, b2, c2) = (a, b, c)
	while a > 0 and b > 1:
		a -= 1
		b -= 2
		max1 += 3
	while b > 0 and c > 1:
		b -= 1
		c -= 2
		max1 += 3
	while b2 > 0 and c2 > 1:
		b2 -= 1
		c2 -= 2
		max2 += 3
	while a2 > 0 and b2 > 1:
		a2 -= 1
		b2 -= 2
		max2 += 3
	print(max(max1, max2))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	b1 = b // 2
	a1 = a // 2
	if c % 2 == 1:
		m1 = min(c - 1, 2 * b) + min(c - 1, 2 * b) / 2
	else:
		m1 = min(c, 2 * b) + min(c, 2 * b) / 2
	b = b - m1 / 3
	if b % 2 == 1:
		m2 = min(b - 1, 2 * a) + min(b - 1, 2 * a) / 2
	else:
		m2 = min(b, 2 * a) + min(b, 2 * a) / 2
	print(int(m1 + m2))


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


x = int(input())
ans = []
for i in range(x):
	su = 0
	y = list(map(int, input().split()))
	if y[1] == 0:
		ans.append(0)
		continue
	if y[2] > 0:
		y[2] = y[2] // 2
		su = min(y[1], y[2]) * 3
		y[1] = y[1] - su // 3
	y[1] = y[1] // 2
	ans.append(min(y[0], y[1]) * 3 + su)
for i in ans:
	print(i)


t = int(input())
while t:
	(a, b, c) = map(int, input().split())
	ans = 3 * min(b, c // 2)
	b -= min(b, c // 2)
	c -= 2 * min(b, c // 2)
	ans += 3 * min(a, b // 2)
	print(ans)
	t -= 1


t = int(input())
for i in range(t):
	(a, b, c) = input().split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	ans = 0
	if b == 0:
		print('0')
	else:
		n = int(c / 2)
		if n:
			if b - n > 0:
				b -= n
				c -= 2 * n
				ans += 3 * n
			else:
				c = c - 2 * b
				ans += 3 * b
				b = 0
		n = int(b / 2)
		if n:
			if a - n > 0:
				a -= n
				b -= 2 * n
				ans += 3 * n
			elif a > 0:
				b = b - 2 * a
				ans += 3 * a
				a = 0
		print(ans)


dp = {}

def max_stones(a, b, c):
	if a < 1 and b < 1 or (a < 1 and c < 2):
		return 0
	elif (a, b, c) in dp.keys():
		return dp[a, b, c]
	else:
		(opt1, opt2) = (0, 0)
		if a >= 1 and b >= 2:
			opt1 = 3 + max_stones(a - 1, b - 2, c)
		if b >= 1 and c >= 2:
			opt2 = 3 + max_stones(a, b - 1, c - 2)
		dp[a, b, c] = max(opt1, opt2)
		return dp[a, b, c]
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().strip().split(' '))
	ans = max_stones(a, b, c)
	print(ans)


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


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	ans = 0
	x = c // 2
	if b >= x:
		ans += x + 2 * x
		b -= x
	else:
		ans += b + 2 * b
		b -= b
	y = b // 2
	if a >= y:
		ans += y + 2 * y
		a -= y
	else:
		ans += a + 2 * a
	print(ans)


T_ON = 1
DEBUG_ON = 0
MOD = 998244353

def solve():
	(a, b, c) = read_ints()
	y = min(b, c // 2)
	b -= y
	x = min(a, b // 2)
	print(3 * (x + y))

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


def f(x, y):
	if y >= x * 2:
		return x * 3
	return y // 2 * 3

def main():
	import sys, bisect
	input = sys.stdin.readline
	t = int(input())
	for __ in [0] * t:
		(a, b, c) = map(int, input().split())
		res = 0
		if b >= 2 * a:
			res = max(res, 3 * a + f(b - 2 * a, c))
		if b >= c // 2:
			res = max(res, c // 2 * 3 + f(a, b - c // 2))
		for k in range(b + 1):
			if c >= 2 * k:
				res = max(res, 3 * k + f(a, b - k))
		print(res)
main()


from math import *
t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = map(int, input().split())
	res = 0
	if b >= c // 2:
		b = b - c // 2
		res += c // 2 * 3
		if a >= b // 2:
			a = a - b // 2
			res += b // 2 * 3
		else:
			res += a * 3
	else:
		res += b * 3
	print(res)


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for _ in range(test):
	(a, b, c) = multi_int_input()
	ball = 0
	while c > 1:
		if b > 0:
			b -= 1
			c -= 2
			ball += 3
		else:
			break
	while b > 1:
		if a > 0:
			a -= 1
			b -= 2
			ball += 3
		else:
			break
	print(ball)


for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	if a[1] == 0:
		ans = 0
	else:
		from_3_2 = a[2] // 2
		if from_3_2 >= a[1]:
			ans = 3 * a[1]
		else:
			a[1] -= from_3_2
			from_2_1 = a[1] // 2
			times = min(from_2_1, a[0])
			ans = 3 * from_3_2 + 3 * times
	print(ans)


n = int(input())
for i in range(n):
	line = [int(x) for x in input().split(' ')]
	c = line[2] // 2
	if c < line[1]:
		print(int(3 * c + 3 * min((line[1] - c) // 2, line[0])))
	else:
		print(int(3 * line[1]))


import sys, atexit
from io import BytesIO
inp = BytesIO(sys.stdin.buffer.read())
input = lambda : inp.readline().decode('ascii')
buf = BytesIO()
atexit.register(lambda : sys.__stdout__.buffer.write(buf.getvalue()))
for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	ans = 0
	x = y = 0
	c = c // 2 * 2
	x = min(c // 2, b)
	b -= x
	b = b // 2 * 2
	y = min(b // 2, a)
	print(x * 3 + y * 3)


t = int(input())
for x in range(t):
	stones = list(map(int, input().split()))
	alice_stones = 0
	first_heap_stones = stones[0]
	last_heap_stones = stones[2]
	while stones[1] != 0:
		if stones[1] > 0 and stones[2] >= 2:
			stones[1] -= 1
			stones[2] -= 2
			alice_stones += 3
		elif stones[0] > 0 and stones[1] >= 2:
			stones[0] -= 1
			stones[1] -= 2
			alice_stones += 3
		else:
			break
	print(alice_stones)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
dp = [[[-1 for i in range(101)] for j in range(101)] for k in range(101)]

@iterative
def rec(a, b, c):
	if dp[a][b][c] != -1:
		yield dp[a][b][c]
	temp = 0
	if a > 0 and b > 1:
		temp = max(temp, 3 + (yield rec(a - 1, b - 2, c)))
	if b > 0 and c > 1:
		temp = max(temp, 3 + (yield rec(a, b - 1, c - 2)))
	dp[a][b][c] = temp
	yield temp

def solve():
	(a, b, c) = sep()
	print(rec(a, b, c))
testcase(int(inp()))


import math
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	count = 0
	if b == 0:
		print('0')
	elif a == 0:
		while b >= 1 and c > 1:
			b = b - 1
			count = count + 1
			c = c - 2
			count = count + 2
		print(count)
	elif c == 0:
		while a >= 1 and b > 1:
			a = a - 1
			count = count + 1
			b = b - 2
			count = count + 2
		print(count)
	else:
		while b >= 1 and c > 1:
			b = b - 1
			count = count + 1
			c = c - 2
			count = count + 2
		while a >= 1 and b > 1:
			a = a - 1
			count = count + 1
			b = b - 2
			count = count + 2
		print(count)


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	k = c // 2
	sum1 = 0
	if b < k:
		sum1 += b * 1 + b * 2
		b = 0
	elif b >= k:
		sum1 += k * 1 + k * 2
		b = b - k
	k = b // 2
	if a < k:
		sum1 += a * 1 + a * 2
	elif a >= k:
		sum1 += k * 1 + k * 2
	print(sum1)
	t -= 1


n = int(input())
mli = []
for i in range(n):
	tli = []
	tli = list(map(int, input().split(' ')))
	mli.append(tli)
for i in range(n):
	init = 0
	while mli[i][1] >= 1 and mli[i][2] >= 2:
		init = init + 3
		mli[i][1] = mli[i][1] - 1
		mli[i][2] = mli[i][2] - 2
	while mli[i][0] >= 1 and mli[i][1] >= 2:
		init = init + 3
		mli[i][0] = mli[i][0] - 1
		mli[i][1] = mli[i][1] - 2
	print(init)


def solve(a, b, c, v):
	x = min(c // 2, b)
	return x + min(a, (b - x) // 2)

def main():
	for _ in range(int(input())):
		(a, b, c) = list(map(int, input().split()))
		print(3 * solve(a, b, c, 0))
main()


test = int(input())
while test > 0:
	inp = input().split()
	x = int(inp[0])
	y = int(inp[1])
	z = int(inp[2])
	c = 0
	while z > 1 and y > 0:
		z -= 2
		y -= 1
		c += 3
	while x > 0 and y > 1:
		x -= 1
		y -= 2
		c += 3
	print(c)
	test -= 1


t = int(input())
count = 0
ans = []
while count < t:
	sto = input()
	(a, b, c) = sto.split()
	if int(b) == 0:
		ans.append(0)
	elif int(c) != 0:
		times = int(c) // 2
		if int(b) < times:
			tot = int(b) + int(b) * 2
			ans.append(tot)
		else:
			tot = times + times * 2
			b = int(b) - times
			if b < 2 or int(a) == 0:
				ans.append(tot)
			else:
				times2 = int(b) // 2
				if times2 < int(a):
					tot += times2 + times2 * 2
					ans.append(tot)
				else:
					tot += int(a) + int(a) * 2
					ans.append(tot)
	elif int(a) != 0:
		tot = 0
		times2 = int(b) // 2
		if times2 < int(a):
			tot += times2 + times2 * 2
			ans.append(tot)
		else:
			tot += int(a) + int(a) * 2
			ans.append(tot)
	else:
		ans.append(0)
	count += 1
for y in ans:
	print(y)


import sys
input = sys.stdin.buffer.readline
t = int(input())
for i in range(t):
	(a, b, c) = [int(item) for item in input().split()]
	ans = 0
	for i in range(55):
		for j in range(55):
			if i <= a and i * 2 + j <= b and (j * 2 <= c):
				ans = max(ans, i * 3 + j * 3)
	print(ans)


t = int(input())
i = 0
while i < t:
	mass = list(input().split())
	a = int(mass[0])
	b = int(mass[1])
	c = int(mass[2])
	answer = 0
	while c > 1 and b > 0:
		b -= 1
		c -= 2
		answer += 3
	while b > 1 and a > 0:
		b -= 2
		a -= 1
		answer += 3
	print(answer)
	i += 1


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


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


t = int(input())
for i in range(t):
	count = 0
	(a, b, c) = list(map(int, input().split(' ')))
	p = c // 2
	if b >= p:
		count += 3 * p
		b -= p
	else:
		count += 3 * b
		b = 0
	if b != 0:
		if a >= b // 2:
			count += 3 * (b // 2)
		else:
			count += 3 * a
	print(count)


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


from collections import defaultdict as dc
from collections import deque as dq
from bisect import bisect_left, bisect_right, insort_left
import sys
import math
mod = 10 ** 9 + 7

def bs(a, x):
	i = bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def inp():
	p = sys.stdin.readline()
	return p

def line():
	p = list(map(int, inp().split()))
	return p

def ans(a, b):
	c = 0
	if a * 2 > b:
		x = b // 2
		b = b % 2
		c = c + x * 2 + x
		a = a - x
	else:
		x = a
		a = 0
		b = b - x * 2
		c = c + x * 2 + x
	return (a, b, c)

def ans1(a, b, c):
	an = 0
	for i in range(0, b + 1, 2):
		an = max(an, ans(a, i)[2] + ans(b - i, c)[2])
	return an
n = int(inp())
for i in range(n):
	(a, b, c) = line()
	print(ans1(a, b, c))


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


t = int(input())
for i in range(t):
	inp = input()
	inp_arr = inp.split(' ')
	a = int(inp_arr[0])
	b = int(inp_arr[1])
	c = int(inp_arr[2])
	set1 = set()
	for n in range(0, a + 1):
		for m in range(0, c // 2 + 1):
			if 2 * n + m <= b:
				set1.add(3 * (m + n))
	print(max(set1))


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


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


num = int(input())
for i in range(num):
	(a, b, c) = map(int, input().split())

	def sum1(a, b, c):
		sum = 0
		while True:
			if a >= 1 and b >= 2:
				a -= 1
				b -= 2
				sum += 3
			elif b >= 1 and c >= 2:
				b -= 1
				c -= 2
				sum += 3
			else:
				break
		return sum

	def sum2(a, b, c):
		sum = 0
		while True:
			if b >= 1 and c >= 2:
				b -= 1
				c -= 2
				sum += 3
			elif a >= 1 and b >= 2:
				a -= 1
				b -= 2
				sum += 3
			else:
				break
		return sum
	print(max(sum1(a, b, c), sum2(a, b, c)))


t = int(input())
for i in range(t):
	[a, b, c] = list(map(float, input().split()))
	s = 0
	s1 = min(b, c // 2)
	b -= s1
	c -= 2 * s1
	s2 = min(a, b // 2)
	s = 3 * (s1 + s2)
	print(int(s))


import sys
import math
fileoperation = 0
if fileoperation:
	orig_stdout = sys.stdout
	orig_stdin = sys.stdin
	inputfile = open('W:/Competitive Programming/input.txt', 'r')
	outputfile = open('W:/Competitive Programming/output.txt', 'w')
	sys.stdin = inputfile
	sys.stdout = outputfile
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(a, b, c) = map(int, sys.stdin.readline().split(' '))
	x = a
	y = b
	z = c
	a1 = 0
	v = min(a, b // 2)
	a1 += 3 * v
	b %= 2
	v = min(b, c // 2)
	a1 += 3 * v
	a2 = 0
	v = min(y, z // 2)
	a2 += 3 * v
	y -= v
	v = min(x, y // 2)
	a2 += 3 * v
	print(max(a1, a2))
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_strList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
for _ in range(n):
	(a, b, c) = get_list()
	count = 0
	if 2 * b >= c:
		count += 3 * (c // 2)
		b = b - c // 2
		if b > 1 and a >= b // 2:
			count += 3 * (b // 2)
		elif b > 1 and a < b // 2:
			count += 3 * a
	else:
		count += 3 * b
	print(count)


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


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


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if c % 2 == 1:
		c = c - 1
	c1 = min(2 * b, c)
	a1 = min((b - c1 // 2) // 2, a)
	print(2 * a1 + c1 // 2 + a1 + c1)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	ans1 = 0
	ans2 = 0
	(a1, b1, c1) = (a, b, c)
	while b > 0 and c > 1:
		ans1 += 3
		b -= 1
		c -= 2
	while a > 0 and b > 1:
		ans1 += 3
		b -= 2
		a -= 1
	while a1 > 0 and b1 > 1:
		ans2 += 3
		b1 -= 2
		a1 -= 1
	while b1 > 0 and c1 > 1:
		ans2 += 3
		b1 -= 1
		c1 -= 2
	print(max(ans1, ans2))


import math
cases = int(input())
tests = []
for i in range(cases):
	tests.append(input().split())

def times(a, b, c):
	limit = min(math.floor(c / 2), b)
	limit = limit + min(math.floor((b - limit) / 2), a)
	return limit
for test in tests:
	print(times(int(test[0]), int(test[1]), int(test[2])) * 3)


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


num = int(input())
while num:
	arr = list(map(int, input().split()))
	total = 0
	while arr[1] >= 1 and arr[2] >= 2:
		total += 3
		arr[1] = arr[1] - 1
		arr[2] = arr[2] - 2
	while arr[0] >= 1 and arr[1] >= 2:
		total += 3
		arr[0] -= 1
		arr[1] = arr[1] - 2
	print(total)
	num -= 1


import sys, math, bisect

def input():
	return sys.stdin.readline()[:-1]

def main():
	t = int(input())
	for _ in range(t):
		(a, b, c) = map(int, input().split())
		ans = 0
		for p in range(51):
			for q in range(51):
				if a - p >= 0 and b - 2 * p - q >= 0 and (c - 2 * q >= 0):
					ans = max(ans, 3 * (p + q))
		print(ans)
main()


nb = int(input())
L = []
for i in range(nb):
	L.append(input())
for i in range(len(L)):
	L[i] = L[i].split()
for i in range(len(L)):
	for j in range(len(L[i])):
		L[i][j] = int(L[i][j])
for i in range(len(L)):
	count = 0
	while L[i][1] > 0 and L[i][2] > 1:
		L[i][1] = L[i][1] - 1
		L[i][2] = L[i][2] - 2
		count += 3
	while L[i][1] > 1 and L[i][0] > 0:
		L[i][0] = L[i][0] - 1
		L[i][1] = L[i][1] - 2
		count += 3
	print(count)


def int_lst_input():
	return [int(val) for val in input().split()]

def int_input():
	return int(input())

def print_lst(lst):
	print(' '.join([str(val) for val in lst]))

def dec_ab_inc_stones(a, b, stones):
	return (a - 1, b - 2, stones + 3)

def solve():
	t = int_input()
	for _ in range(t):
		(a, b, c) = int_lst_input()
		if b == 0:
			print(0)
			continue
		(ans, cnt) = (0, 0)
		x = min(a, b // 2)
		rem = b - 2 * x
		cnt += 3 * x
		x = min(rem, c // 2)
		cnt += 3 * x
		ans = cnt
		cnt = 0
		x = min(b, c // 2)
		rem = b - x
		cnt += 3 * x
		x = min(rem // 2, a)
		cnt += 3 * x
		print(max(ans, cnt))
solve()


t = int(input())
l = []
for i in range(t):
	h = tuple(map(int, input().split()))
	l.append(h)
for h in l:
	s1 = 0
	s2 = 0
	m1 = 0
	m2 = 0
	a = h[0]
	b = h[1]
	c = h[2]
	a1 = a
	a2 = a
	b1 = b
	b2 = b
	c1 = c
	c2 = c
	while a1 > 0 and b1 > 1:
		s1 = s1 + 3
		b1 = b1 - 2
		a1 = a1 - 1
	while b1 > 0 and c1 > 1:
		s2 = s2 + 3
		b1 = b1 - 1
		c1 = c1 - 2
	while b2 > 0 and c2 > 1:
		m2 = m2 + 3
		b2 = b2 - 1
		c2 = c2 - 2
	while a2 > 0 and b2 > 1:
		m1 = m1 + 3
		b2 = b2 - 2
		a2 = a2 - 1
	print(max(s1 + s2, m1 + m2))


import sys

def get_single_int():
	return int(sys.stdin.readline().strip())

def get_string():
	return sys.stdin.readline().strip()

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
for i in range(get_single_int()):
	(a, b, c) = get_ints()
	summ = 0
	while b > 0 and c > 1:
		b -= 1
		c -= 2
		summ += 3
	if b == 0:
		print(summ)
		continue
	else:
		while b > 1 and a > 0:
			b -= 2
			a -= 1
			summ += 3
	print(summ)


import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
	return int(input())

def getList():
	return list(map(int, input().split()))
import math

def solve():
	(a, b, c) = getList()
	ans = 0
	ans += min(b, c // 2) * 3
	b -= ans // 3
	ans += min(a, b // 2) * 3
	print(ans)

def main():
	t = getN()
	for times in range(t):
		solve()
main()


import sys
import os
from io import IOBase, BytesIO

def main():
	for tc in range(int(input())):
		(a, b, c) = get_ints()
		ans = 0
		while b > 0 and c > 1:
			ans += 3
			b -= 1
			c -= 2
		while a > 0 and b > 1:
			ans += 3
			a -= 1
			b -= 2
		print(ans)
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		py2 = round(0.5)
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2 == 1:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

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

def get_ints():
	return map(int, sys.stdin.readline().split())

def input():
	return sys.stdin.readline().strip()
main()


t = int(input())
for i in range(0, t):
	l = list(map(int, input().split()))
	n1 = min(l[2] // 2, l[1])
	l[1] -= n1
	n2 = min(l[1] // 2, l[0])
	print((n1 + n2) * 3)


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


t = int(input())
ans = []
for i in range(t):
	(a, b, c) = list(map(int, input().split()))
	j = c // 2
	if b > j:
		b = b - j
		k = b // 2
		if a > k:
			j = j + k
			ans.append(3 * j)
		else:
			j = j + a
			ans.append(3 * j)
	else:
		ans.append(3 * b)
for i in range(t):
	print(ans[i])


def solve(a, b, c):
	(a1, b1, c1) = (a, b, c)
	count = 0
	t = min(b, c // 2)
	count += 3 * t
	b -= t
	c -= 2 * t
	t = min(a, b // 2)
	count += 3 * t
	(a, b, c) = (a1, b1, c1)
	count1 = 0
	t = min(a, b // 2)
	count1 += 3 * t
	a -= t
	b -= 2 * t
	t = min(b, c // 2)
	count1 += 3 * t
	return max(count, count1)
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(solve(a, b, c))


for i in range(int(input())):
	(n, m, l) = list(map(int, input().split()))
	k = min(m, l // 2)
	h = min(n, (m - k) // 2)
	print(3 * (k + h))


t = int(input())
for i in range(t):
	(a, b, c) = [int(x) for x in input().split()]
	sum = 0
	if c // 2 > b:
		sum += b * 3
	else:
		sum += c // 2 * 3
		b -= c // 2
		if b // 2 > a:
			sum += a * 3
		else:
			sum += b // 2 * 3
	print(sum)


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


def mn(a, b):
	if a < b:
		return a
	else:
		return b
t = int(input())
if t >= 1 and t <= 100:
	for _ in range(t):
		l = list(map(int, input().split()))
		if min(l) >= 0 and max(l) <= 100:
			count = 0
			count += 3 * mn(l[2] // 2, l[1])
			count += 3 * mn((l[1] - count // 3) // 2, l[0])
			print(count)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	res = 0
	possible = True
	while possible:
		if b >= 1 and c >= 2:
			c1 = min(c // 2, b)
			res += c1 * 3
			b -= c1
			c -= c1 * 2
		elif b >= 2 and a >= 1:
			b1 = min(b // 2, a)
			res += b1 * 3
			b -= b1 * 2
			a -= b1
		else:
			possible = False
	print(res)


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))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	k = min(b // 1, c // 2)
	s = 0
	if k != 0:
		s = k * 3
		b = b - k
		c = c - k * 2
	m = min(a // 1, b // 2)
	s = s + m * 3
	print(s)


t = int(input())
xx = []
for i in range(t):
	xx.append(input().split())
for x in xx:
	m2 = int(x[2]) // 2
	m2 = int(x[1]) if m2 > int(x[1]) else m2
	x[1] = int(x[1]) - m2
	m1 = int(x[1]) // 2
	m1 = int(x[0]) if m1 > int(x[0]) else m1
	print((m1 + m2) * 3)


count = int(input())
sets = []
while count > 0:
	sets.append(list(map(int, input().split())))
	count -= 1
stones = 0
for _set in sets:
	if _set[1] == 0:
		print(0)
		continue
	while _set[2] > 1 and _set[1] > 0:
		stones += 3
		_set[2] -= 2
		_set[1] -= 1
	while _set[1] > 1 and _set[0] > 0:
		stones += 3
		_set[1] -= 2
		_set[0] -= 1
	print(stones)
	stones = 0


t = int(input())
while t:
	t -= 1
	ans = 0
	(x, y, z) = [int(x) for x in input().split()]
	temp = z // 2
	temp = min(y, temp)
	ans = 3 * temp
	y -= temp
	temp = y // 2
	temp = min(temp, x)
	ans = ans + 3 * temp
	print(ans)


n = int(input())
elems = []
for _ in range(n):
	elems.append(tuple(map(int, input().split())))

def solve(elem):
	(a, b, c) = elem
	temp = 0
	while 2 * temp <= c and temp <= b:
		temp += 1
	t1 = temp - 1
	(a, b, c) = (a, b - t1, c - 2 * t1)
	temp = 0
	while 2 * temp <= b and temp <= a:
		temp += 1
	t2 = temp - 1
	print(t1 + 2 * t1 + t2 + 2 * t2)
for elem in elems:
	solve(elem)


t = int(input())
while t:
	(a, b, c) = [int(x) for x in input().split()]
	(ans1, ans2) = (0, 0)
	(a1, b1, c1) = (a, b, c)
	act1 = min(a, b // 2)
	ans1 += act1 + act1 * 2
	a -= act1
	b -= act1 * 2
	act2 = min(b, c // 2)
	ans1 += act2 + act2 * 2
	act1 = min(b1, c1 // 2)
	ans2 += act1 + act1 * 2
	b1 -= act1
	c1 -= act1 * 2
	act2 = min(a1, b1 // 2)
	ans2 += act2 + act2 * 2
	print(max(ans1, ans2))
	t -= 1


n = int(input())
for _ in range(n):
	(a, b, c) = map(int, input().split())
	stones = 0
	pairc = 0
	paira = 0
	pairc = c // 2
	if pairc <= b:
		stones += pairc + 2 * pairc
		b -= pairc
	else:
		stones = b + b * 2
		b = 0
	paira = b // 2
	if paira < a:
		stones += paira + 2 * paira
	else:
		stones += a + a * 2
	print(stones)


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


casos = int(input())
for i in range(casos):
	(pilha1, pilha2, pilha3) = [int(x) for x in input().split()]
	contador = 0
	while pilha3 > 1 and pilha2 != 0:
		pilha3 -= 2
		pilha2 -= 1
		contador += 3
	while pilha2 > 1 and pilha1 != 0:
		pilha2 -= 2
		pilha1 -= 1
		contador += 3
	print(contador)


def solve(a, b, c):
	x = min(c // 2, b)
	return 3 * (x + min(a, (b - x) // 2))

def solve2(a, b, c):
	global d
	if (a, b, c) in d:
		return d[a, b, c]
	op1 = a >= 1 and b >= 2
	op2 = b >= 1 and c >= 2
	if not (op1 or op2):
		x = 0
	elif not op1 and op2:
		x = solve2(a, b - 1, c - 2) + 3
	elif op1 and (not op2):
		x = solve2(a - 1, b - 2, c) + 3
	else:
		x = max(solve2(a - 1, b - 2, c), solve2(a, b - 1, c - 2)) + 3
	d[a, b, c] = x
	return x

def main():
	global d
	for _ in range(int(input())):
		(a, b, c) = list(map(int, input().split()))
		d = {}
		print(solve2(a, b, c))
main()


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


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	summa = 0
	while 1:
		if b > c and a > 0 and (b > 1):
			a -= 1
			b -= 2
			summa += 3
		elif (b <= c or a == 0) and b > 0 and (c > 1):
			b -= 1
			c -= 2
			summa += 3
		else:
			print(summa)
			break


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)


for i in range(int(input())):
	a = list(input().split())
	b = [int(j) for j in a]
	k = b[2] // 2
	if k <= b[1]:
		b[1] = b[1] - k
		if b[1] // 2 <= b[0]:
			print(3 * (k + b[1] // 2))
		else:
			print(3 * (k + b[0]))
	else:
		print(3 * b[1])


def take(a, b, answer):
	return (a - 1, b - 2, answer + 3)
k = int(input())
for i in range(0, k):
	answer = 0
	(a, b, c) = map(int, input().split())
	while c >= 2 and b >= 1:
		(b, c, answer) = take(b, c, answer)
	while b >= 2 and a >= 1:
		(a, b, answer) = take(a, b, answer)
	print(answer)


n = int(input())
for _ in range(n):
	(a, b, c) = map(int, input().split())
	res = 0
	c2 = c // 2
	if b < c2:
		res += b
		res += b * 2
		b = 0
	else:
		res += c2 * 2
		res += c2
		b -= c2
	b2 = b // 2
	if a < b2:
		res += a
		res += a * 2
	else:
		res += b2 * 2
		res += b2
	print(res)


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


q = int(input())
for qq in range(q):
	(a, b, c) = [int(s) for s in input().split()]
	x = min(b, c // 2)
	b -= x
	y = min(a, b // 2)
	print(3 * (x + y))


for _ in range(int(input())):
	(a, b, c) = list(map(int, input().split()))
	count = 0
	maxC = c // 2
	if b > maxC:
		count += 3 * maxC
		b = b - maxC
	else:
		count += 3 * b
		b = 0
	maxB = b // 2
	if a > maxB:
		count += 3 * maxB
	else:
		count += 3 * a
	print(count)


t = int(input())
for k in range(t):
	(a, b, c) = map(int, input().split())
	ti = t
	result = 0
	while True:
		if c >= 2 and b >= 1:
			result += 3
			c -= 2
			b -= 1
		elif b >= 2 and a >= 1:
			result += 3
			b -= 2
			a -= 1
		else:
			break
	print(result)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	co = 0
	e = c // 2
	if b <= e:
		co += 3 * b
	else:
		co += 3 * e
		b = b - e
		f = b // 2
		if a <= f:
			co += 3 * a
		else:
			co += 3 * f
	print(co)


def solve(a, b, c):
	cnt = 0
	if b >= 1 and c >= 2:
		x = c // 2
		rem = c % 2
		if x <= b:
			cnt += x
			b = b - x
			c = rem
		else:
			cnt += b
			b = 0
			c = c - 2 * b
	if b > 1 and a > 0:
		x = b // 2
		rem = b % 2
		if x <= a:
			cnt += x
			a = a - x
			b = rem
		else:
			cnt += a
			a = 0
			b = b - 2 * a
	return cnt * 3
for i in range(int(input())):
	(a, b, c) = list((int(x) for x in input().split()))
	print(solve(a, b, c))


t = int(input())
m = 0
while m < t:
	s = list(map(int, input().split()))
	a = s[0]
	b = s[1]
	c = s[2]
	k = 0
	if b == 0:
		print(0)
	else:
		while c > 1 and b > 0:
			k = k + 3
			c = c - 2
			b = b - 1
		while b > 1 and a > 0:
			k = k + 3
			b = b - 2
			a = a - 1
		print(k)
	m = m + 1


t = int(input())
a = []
for i in range(t):
	k = list(map(int, input().split()))
	a.append(k)
	n = 0
	while a[i][1] >= 1 and a[i][2] >= 2:
		a[i][1] -= 1
		a[i][2] -= 2
		n += 3
	while a[i][0] >= 1 and a[i][1] >= 2:
		a[i][0] -= 1
		a[i][1] -= 2
		n += 3
	print(n)


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	bh = b // 2
	ch = c // 2
	m1 = min(a, bh)
	m2 = min(b, ch)
	m1 = m1 * 3 + min(b - m1 * 2, ch) * 3
	m2 = m2 * 3 + min(a, (b - m2) // 2) * 3
	if m1 > m2:
		print(m1)
	else:
		print(m2)
	t = t - 1


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	for x in range(100):
		for y in range(100):
			if x <= a and x * 2 <= b and (y <= b - 2 * x) and (2 * y <= c):
				ans = max(ans, 3 * (x + y))
	print(ans)


t = int(input())
for _ in range(t):
	(a1, b1, c1) = map(int, input().split())
	(a2, b2, c2) = (a1, b1, c1)
	ans1 = min(a1, b1 // 2)
	b1 -= 2 * ans1
	ans1 += min(b1, c1 // 2)
	ans2 = min(b2, c2 // 2)
	b2 -= ans2
	ans2 += min(a2, b2 // 2)
	print(max(ans1, ans2) * 3)


from sys import stdin
t = int(stdin.readline().rstrip())
while t > 0:
	(a, b, c) = map(int, stdin.readline().split())
	s = 0
	s += min(b, c // 2) * 3
	b -= min(b, c // 2)
	s += min(a, b // 2) * 3
	print(s)
	t -= 1


n = int(input())
while n:
	z = 0
	counter = 0
	(a, b, c) = map(int, input().split())
	while b >= 1 and c >= 2:
		b -= 1
		c -= 2
		z += 3
		counter += 1
		if a >= 1 and b >= 2:
			pass
		else:
			z += 0
	while a >= 1 and b >= 2:
		a -= 1
		b -= 2
		z += 3
		counter += 1
		if b >= 1 and c >= 2:
			pass
		else:
			z += 0
	print(z)
	n -= 1


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)


t = int(input())
for i in range(t):
	li = list(map(int, input().split()))
	a = li[0]
	b = li[1]
	c = li[2]
	maxbottom = int(li[2] / 2)
	if li[1] - 1 > maxbottom:
		li[1] = li[1] - maxbottom
		maxmiddle = int(li[1] / 2)
		print((min(li[0], maxmiddle) + maxbottom) * 3)
	else:
		print(min(maxbottom, li[1]) * 3)


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


import sys
import itertools
import math
import collections
from collections import Counter

def pow(x, y, mod):
	r = 1
	x = x % mod
	while y > 0:
		if y & 1:
			r = r * x % mod
		y = y >> 1
		x = x * x % mod
	return r

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

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)
t = ii()
for i in range(t):
	(a, b, c) = mi()
	t = min(c // 2, b)
	b = max(0, b - t)
	r = t + min(a, b // 2)
	print(r * 3)


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


t = int(input())
for p in range(t):
	(a, b, c) = [int(s) for s in input().split()]
	if c % 2:
		c -= 1
	if 2 * a + c // 2 <= b:
		ans = 3 * (a + c // 2)
		print(ans)
		continue
	if c // 2 <= b:
		y = c // 2
		x = min(a, (b - y) // 2)
		ans = 3 * (x + y)
		print(ans)
		continue
	else:
		ans = 3 * b
		print(ans)


for _ in range(int(input())):
	l = list(map(int, input().split()))
	ll = [i for i in l]
	ans = 0
	a1 = 0
	x = min(l[2] // 2, l[1])
	l[2] -= x * 2
	l[1] -= x
	a1 += x + x * 2
	y = min(l[1] // 2, l[0])
	l[2] -= y * 2
	l[1] -= y
	a1 += y + y * 2
	a2 = 0
	x = min(l[1] // 2, l[0])
	l[1] -= x * 2
	l[0] -= x
	a2 += x + x * 2
	y = min(l[2] // 2, l[1])
	l[2] -= y * 2
	l[1] -= y
	a2 += y + y * 2
	print(max(a1, a2))


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)))


import sys
t = int(sys.stdin.readline())
for i in range(t):
	[a, b, c] = [int(i) for i in sys.stdin.readline().split()]
	st2 = min(b, c // 2)
	b -= st2
	c -= st2 * 2
	st1 = min(a, b // 2)
	a -= st1
	b -= st1 * 2
	print(3 * (st1 + st2))


t = int(input())
for kcase in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	if b <= c // 2:
		ans = ans + 3 * b
		b = 0
	else:
		ans = ans + 3 * (c // 2)
		b = b - c // 2
	if b // 2 >= a:
		ans = ans + 3 * a
	else:
		ans = ans + 3 * (b // 2)
	print(ans)


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


t = int(input())
while t != 0:
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	sum = 0
	while b >= 1 and c >= 2:
		sum += 3
		b = b - 1
		c = c - 2
	while a >= 1 and b >= 2:
		sum += 3
		b = b - 2
		a = a - 1
	print(sum)
	t -= 1


T = int(input())
for t in range(T):
	(a, b, c) = list(map(int, input().split()))
	sum = 0
	if b == 0:
		print(0)
		continue
	elif b >= c // 2:
		b = b - c // 2
		sum += 3 * (c // 2)
		if a >= b // 2:
			sum += 3 * (b // 2)
		else:
			sum += 3 * a
	else:
		sum += 3 * b
	print(sum)


n = int(input())
for i in range(n):
	(a, b, c) = [int(i) for i in input().split()]
	cost = 0
	while a >= 1 and b >= 2 or (b >= 1 and c >= 2):
		if b > c and a >= 1:
			cost += 3
			b -= 2
			a -= 1
		else:
			cost += 3
			c -= 2
			b -= 1
	print(cost)


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


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


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


t = int(input())
for i in range(t):
	(a, b, c) = [int(x) for x in input().split()]
	count = 0
	cs = min(b, c // 2)
	count += 3 * cs
	b -= cs
	bs = min(a, b // 2)
	count += 3 * bs
	print(count)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	(d, e, f) = (a, b, c)
	m = 0
	l = []
	while 1:
		if a >= 1 and b >= 2:
			a = a - 1
			b = b - 2
			m = m + 3
		elif b >= 1 and c >= 2:
			b = b - 1
			c = c - 2
			m = m + 3
		else:
			break
	l.append(m)
	m = 0
	while 1:
		if e >= 1 and f >= 2:
			e = e - 1
			f = f - 2
			m = m + 3
		elif d >= 1 and e >= 2:
			d = d - 1
			e = e - 2
			m = m + 3
		else:
			break
	l.append(m)
	print(max(l))


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	(a, b, c) = inpl()
	res = 0
	while b > 0 and c > 1:
		b -= 1
		c -= 2
		res += 3
	while a > 0 and b > 1:
		a -= 1
		b -= 2
		res += 3
	print(res)


from copy import deepcopy

class st:
	pass

def take1(st):
	f = min(st.a, st.b // 2)
	st.a -= f
	st.b -= 2 * f
	return f * 3

def take2(st):
	f = min(st.b, st.c // 2)
	st.b -= f
	st.c -= 2 * f
	return f * 3

def solve(I):
	st = deepcopy(I)
	res1 = take1(st) + take2(st)
	st = deepcopy(I)
	res2 = take2(st) + take1(st)
	return max(res1, res2)
for i in range(int(input())):
	s = st()
	(s.a, s.b, s.c) = map(int, input().split())
	print(solve(s))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if b == 0:
		print(0)
	elif b == 1:
		if c >= 2:
			print(3)
		else:
			print(0)
	else:
		k = min(b, c // 2)
		b -= k
		k += min(a, b // 2)
		print(3 * k)


t = int(input())
while t:
	(a, b, c) = map(int, input().split())
	remp = c // 2
	if remp < b:
		p = (b - remp) // 2
		d = remp * 3
		if p < a:
			d += p * 3
		else:
			p = min(p, a)
			d += p * 3
	else:
		remp = min(remp, b)
		d = remp * 3
	print(d)
	t -= 1


import sys
inputfn = sys.stdin.readline
t = int(inputfn())
for i in range(t):
	total = 0
	piles = inputfn().split(' ')
	piles[0] = int(piles[0])
	piles[1] = int(piles[1])
	piles[2] = int(piles[2])
	if 2 * piles[1] <= piles[2]:
		print(3 * piles[1])
		continue
	total += piles[2] // 2
	piles[1] -= piles[2] // 2
	total += min(piles[0], piles[1] // 2)
	print(3 * total)


def max_stones(a, b, c):
	total = 0
	if c // 2 <= b:
		total += c // 2 * 3
		b -= c // 2
	else:
		return b * 3
	if b // 2 <= a:
		total += b // 2 * 3
	else:
		total += a * 3
	return total
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(max_stones(a, b, c))


def check(a, b):
	if b >= 2 and a >= 1:
		b = b - 2
		a = a - 1
		return 3 + check(a, b)
	else:
		return 0
n = int(input())
result = 0
for i in range(n):
	(a, b, c) = map(int, input().split())
	if b == 0:
		print(0)
	elif a == 0 and c == 0:
		print(0)
	else:
		result = result + check(b, c)
		rb = b - int(check(b, c) / 3)
		result = result + check(a, rb)
		print(result)
		result = 0


ntest = int(input())
for i in range(ntest):
	(a, b, c) = map(int, input().split())
	ans = 0
	for j in range(min(a, b // 2) + 1):
		newb = b - j * 2
		ans = max(ans, j + min(newb, c // 2))
	print(ans * 3)


n = int(input())
out = []
for i in range(n):
	(a, b, c) = map(int, input().split())
	if b >= c // 2:
		if a >= (b - c // 2) // 2:
			out.append((c // 2 + (b - c // 2) // 2) * 3)
		else:
			out.append((c // 2 + a) * 3)
	else:
		out.append(b * 3)
for i in out:
	print(i)


t = int(input())
for it in range(t):
	(a, b, c) = list(map(int, input().split()))
	t1 = min(c // 2, b)
	b -= t1
	c -= 2 * t1
	t2 = min(b // 2, a)
	a -= t2
	b -= 2 * t2
	ms = 3 * (t1 + t2)
	print(ms)


vezes = int(input())
for __ in range(vezes):
	pedras = 0
	(primeiro, segundo, terceiro) = [int(i) for i in input().split()]
	while segundo >= 1 and terceiro >= 2:
		segundo -= 1
		terceiro -= 2
		pedras += 3
	while primeiro >= 1 and segundo >= 2:
		primeiro -= 1
		segundo -= 2
		pedras += 3
	print(pedras)


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


import sys
from math import sqrt, floor, factorial
from collections import deque, Counter
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	for _ in range(int(inp())):
		(a, b, c) = read()
		s = 0
		if b:
			c = min(c - c % 2, b * 2)
			s += c + c // 2
			b -= c // 2
			b = min(b - b % 2, a * 2)
			s += b + b // 2
			print(s)
		else:
			print(s)
solve()


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


import sys, math, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for i in range(t):
	stones = 0
	temp = L()
	while temp[1] > 0 and temp[2] > 1:
		temp[1] -= 1
		temp[2] -= 2
		stones += 3
	while temp[0] > 0 and temp[1] > 1:
		temp[0] -= 1
		temp[1] -= 2
		stones += 3
	print(stones)


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


t = int(input())
for z in range(t):
	(a, b, c) = input().split()
	(a, b, c) = (int(a), int(b), int(c))
	stones = 0
	while True:
		z = 0
		f = 1
		if c > b >= a or c > a >= b:
			if b > 0 and c > 1:
				b -= 1
				c -= 2
				stones += 3
				z = 1
			else:
				z = 0
		elif a >= b >= c or a >= c >= b or b >= c >= a or (b >= a >= c) or (a == b == c):
			if b > 0 and c > 1:
				b -= 1
				c -= 2
				stones += 3
				z = 1
			elif a > 0 and b > 1:
				a -= 1
				b -= 2
				stones += 3
				z = 1
			else:
				z = 0
		if z == 0:
			if a >= b or b >= a:
				if b < 2 or a < 1:
					f = 0
				else:
					f = 1
			elif c >= b:
				if c < 2 or b < 1:
					f = 0
				else:
					f = 1
		if f == 0:
			break
	print(stones)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	x = a
	y = b
	z = c
	while 1:
		if c == 0 or c == 1 or b == 0:
			break
		c = c - 2
		b = b - 1
	while 1:
		if b == 0 or b == 1 or a == 0:
			break
		b = b - 2
		a = a - 1
	print(x - c + (y - b) + (z - a))


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)


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


Q = int(input())
data = []
for _ in range(Q):
	A = list(map(int, input().split()))
	data.append(A)
for (a, b, c) in data:
	ans = 0
	for n in range(b + 1):
		if b - n < 0:
			break
		y = min(n, c // 2) * 3
		x = min((b - n) // 2, a) * 3
		ans = max(ans, x + y)
	print(ans)


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


n = int(input())
while n:
	ans = 0
	(a, b, c) = list(map(int, input().split()))
	while b >= 1 and c >= 2:
		b = b - 1
		c = c - 2
		ans += 3
	while a >= 1 and b >= 2:
		a = a - 1
		b = b - 2
		ans += 3
	print(ans)
	n -= 1


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


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


def xxx(x, y):
	z = y // 2
	a = min(x, z)
	return a
x = int(input())
for i in range(x):
	(a, b, c) = [int(i) for i in input().split()]
	y = 0
	z = xxx(b, c)
	y += z * 3
	z = xxx(a, b - z)
	y += z * 3
	print(y)


n = int(input())
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	p = []
	count = 0
	while b >= 1 and c > 1:
		c = c - 2
		p.append(2)
		b = b - 1
		p.append(1)
	while a > 0 and b > 1:
		b = b - 2
		p.append(2)
		a = a - 1
		p.append(1)
	for j in range(len(p)):
		count += p[j]
	print(count)


q = int(input())
for i in range(q):
	k = 0
	w = list(map(int, input().split()))
	if w[2] // 2 <= w[1]:
		k += 3 * (w[2] // 2)
		w[1] = w[1] - w[2] // 2
	else:
		k += 3 * w[1]
		w[1] = 0
	if w[1] // 2 <= w[0]:
		k += 3 * (w[1] // 2)
	else:
		k += 3 * w[0]
	print(k)


s = int(input())
t = s
for tt in range(t):
	s = input().split()
	a = int(s[0])
	b = int(s[1])
	c = int(s[2])
	ans = 0
	while c:
		if b >= 1 and c >= 2:
			ans += 3
		else:
			break
		b -= 1
		c -= 2
	while a:
		if b >= 2 and a >= 1:
			ans += 3
		else:
			break
		b -= 2
		a -= 1
	print(ans)


cases = int(input())
for k in range(cases):
	(a, b, c) = map(int, input().split())
	resp = 0
	maxa = b // 2
	maxb = c // 2
	if b > c:
		while a >= 1 and b >= 2 and (b > maxb):
			resp += 3
			a -= 1
			b -= 2
		while b >= 1 and c >= 2:
			resp += 3
			b -= 1
			c -= 2
	else:
		while b >= 1 and c >= 2:
			resp += 3
			b -= 1
			c -= 2
		while a >= 1 and b >= 2:
			resp += 3
			a -= 1
			b -= 2
	print(resp)


for _ in range(int(input())):
	acc = 0
	(h1, h2, h3) = list(map(int, input().split(' ')))
	while h3 > 1 and h2 > 0:
		h2 -= 1
		h3 -= 2
		acc += 3
	while h2 > 1 and h1 > 0:
		h2 -= 2
		h1 -= 1
		acc += 3
	print(acc)


import math
for rpt in range(int(input())):
	(a, b, c) = [int(x) for x in input().split(' ')]
	res = 0
	if b < c // 2:
		res += 3 * b
	else:
		res += c // 2 * 3
		b -= c // 2
		if a < b // 2:
			res += a * 3
		else:
			res += b // 2 * 3
	print(res)


t = int(input())
m1 = [0] * t
m2 = [0] * t
m3 = [0] * t
a = [0] * t
for i in range(t):
	(m1[i], m2[i], m3[i]) = map(int, input().split())
for i in range(t):
	while m3[i] >= 2 and m2[i] >= 1:
		a[i] += 3
		m3[i] -= 2
		m2[i] -= 1
	while m2[i] >= 2 and m1[i] >= 1:
		a[i] += 3
		m2[i] -= 2
		m1[i] -= 1
for x in a:
	print(x)


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
input = stdin.readline
for _ in range(int(input())):
	arr = list(map(int, input().split()))
	res = 0
	bf = min(arr[1], arr[2] // 2)
	res += bf * 3
	arr[1] -= bf
	arr[2] -= bf * 2
	bf = min(arr[0], arr[1] // 2)
	res += bf * 3
	print(res)


t = int(input())
for w in range(t):
	l = [int(i) for i in input().split()]
	c = 0
	while l[1] >= 1 and l[2] >= 2:
		c += 3
		l[1] -= 1
		l[2] -= 2
	while l[1] >= 2 and l[0] >= 1:
		c += 3
		l[1] -= 2
		l[0] -= 1
	print(c)


for i in range(int(input())):
	X = list(map(int, input().split()))
	Temp = X[:]
	SUM = 0
	SUM1 = 0
	while X[0] >= 1 and X[1] >= 2:
		SUM += 3
		(X[0], X[1]) = (X[0] - 1, X[1] - 2)
	while X[1] >= 1 and X[2] >= 2:
		SUM += 3
		(X[1], X[2]) = (X[1] - 1, X[2] - 2)
	while Temp[1] >= 1 and Temp[2] >= 2:
		SUM1 += 3
		(Temp[1], Temp[2]) = (Temp[1] - 1, Temp[2] - 2)
	while Temp[0] >= 1 and Temp[1] >= 2:
		SUM1 += 3
		(Temp[0], Temp[1]) = (Temp[0] - 1, Temp[1] - 2)
	print(max(SUM, SUM1))


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


t = int(input())
while t:
	t -= 1
	(a, b, c) = map(int, input().split())
	ans = 0
	uu = min(a, b // 2)
	ans += uu + 2 * uu
	b1 = b - 2 * uu
	uv = min(b1, c // 2)
	ans += uv + 2 * uv
	ans1 = 0
	uu = min(b, c // 2)
	ans1 += uu + 2 * uu
	b1 = b - uu
	uv = min(a, b1 // 2)
	ans1 += uv + 2 * uv
	print(max(ans, ans1))


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)


n = int(input())
while n > 0:
	numbers = input().split(' ')
	a = int(numbers[0])
	b = int(numbers[1])
	c = int(numbers[2])
	cnt = 0
	while b - 1 >= 0 and c - 2 >= 0:
		cnt += 3
		b -= 1
		c -= 2
	while a - 1 >= 0 and b - 2 >= 0:
		cnt += 3
		a -= 1
		b -= 2
	print(cnt)
	n -= 1


n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	c = 0
	if a[1] < 1 and a[2] < 2:
		print('0')
	else:
		if a[1] >= a[2] // 2:
			c = c + a[2] // 2 * 3
			a[1] = a[1] - a[2] // 2
		else:
			c = c + a[1] * 3
			a[1] = 0
		if a[0] >= a[1] // 2:
			c = c + a[1] // 2 * 3
		else:
			c = c + a[0] * 3
		print(c)


def stones(x, y, s):
	if x == 0 or y == 0:
		return (s + 0, x)
	else:
		while x > 0 and y > 1:
			x -= 1
			y -= 2
			s += 3
		return (s, x)
t = int(input())
while t > 0:
	sum = 0
	lst = list(map(int, input().split()))[0:3]
	(final, b) = stones(lst[1], lst[2], 0)
	(sum, c) = stones(lst[0], b, final)
	print(sum)
	t = t - 1


n = int(input())
quer = []
list = [2]
for i in range(n):
	(flag, flag1, flag2) = map(int, input().split())
	a = [flag, flag1, flag2]
	quer.append(a)

def check(quer, i):
	if quer[i] >= 1 and quer[i + 1] >= 2:
		return True
	return False
for i in range(n):
	a = 0
	while check(quer[i], 0) or check(quer[i], 1):
		if quer[i][2] >= 2:
			quer[i][2] -= 2
			quer[i][1] -= 1
			a += 3
		else:
			quer[i][1] -= 2
			quer[i][0] -= 1
			a += 3
	print(a)


t = int(input())
for _ in range(t):
	(a, b, c) = [int(x) for x in input().split()]
	total = 0
	c1 = min(b, c // 2)
	total += c1
	b -= c1
	c -= c1 * 2
	c2 = min(a, b // 2)
	total += c2
	print(total * 3)


def main():
	t = int(input())
	while t is not 0:
		t -= 1
		(a, b, c) = [int(s) for s in input().split()]
		lim = c // 2
		if b < lim:
			print(3 * b)
		else:
			print(3 * lim + min(a, (b - lim) // 2) * 3)
main()


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


count = int(input())
i = 0
res = 0
arr = []
while i < count:
	numbers = input()
	numbers = numbers.split()
	res = 0
	while int(numbers[1]) > 0 and int(numbers[2]) > 1:
		numbers[1] = int(numbers[1]) - 1
		numbers[2] = int(numbers[2]) - 2
		res += 3
	while int(numbers[0]) > 0 and int(numbers[1]) > 1:
		numbers[0] = int(numbers[0]) - 1
		numbers[1] = int(numbers[1]) - 2
		res += 3
	i += 1
	arr.append(res)
i = 0
while i < count:
	print(arr[i])
	i += 1


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


h1 = int(input())
a = []
for i in range(h1):
	c = 0
	(x, y, z) = map(int, input().split())
	h = int(z / 2)
	if h <= y:
		c = c + h * 3
		y = y - h
	else:
		c = c + y * 3
		y = 0
	h = int(y / 2)
	if h <= x:
		c = c + h * 3
	else:
		c = c + x * 3
	a.append(c)
for i in range(h1):
	print(int(a[i]))


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


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


t = int(input(''))
for _ in range(t):
	a = input('').split(' ')
	b = int(a[1])
	c = int(a[2])
	a = int(a[0])
	if b == 0:
		print(0)
		continue
	ans = 0
	if c // 2 <= b:
		ans = 3 * (c // 2)
		b = b - c // 2
		if b >= 2:
			if a >= b // 2:
				ans = ans + 3 * (b // 2)
			else:
				ans = ans + 3 * a
	else:
		ans = b + b * 2
	print(ans)


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


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


import math
for _ in range(int(input())):
	a = [int(n) for n in input().split()]
	b = []
	b += a
	c = 0
	c1 = 0
	while b[1] >= 1 and b[2] >= 2:
		c1 += 3
		b[1] -= 1
		b[2] -= 2
	while b[0] >= 1 and b[1] >= 2:
		c1 += 3
		b[0] -= 1
		b[1] -= 2
	while a[0] >= 1 and a[1] >= 2:
		c += 3
		a[0] -= 1
		a[1] -= 2
	while a[1] >= 1 and a[2] >= 2:
		c += 3
		a[1] -= 1
		a[2] -= 2
	print(max(c, c1))


def answer():
	n = int(input())
	while n:
		a = [int(x) for x in input().split()]
		ans = 0
		a1 = min(a[1], int(a[2] / 2))
		a[1] -= a1
		a2 = min(a[0], int(a[1] / 2))
		ans = 3 * (a1 + a2)
		print(ans)
		n -= 1
answer()


import sys
import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list or type(n) is str:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return '\n'.join(map(str, arr))

def revn(n):
	return int(str(n)[::-1])

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True
t = ii()
for i in range(t):
	(a, b, c) = mi()
	ans = 0
	d = min(b, c // 2)
	ans += d * 3
	b -= d
	e = min(a, b // 2)
	ans += e * 3
	print(ans)


import sys
import math as mt
input = sys.stdin.buffer.readline
t = int(input())
for __ in range(t):
	(x, y, z) = map(int, input().split())
	mini = z // 2
	if mini > y:
		mini = y
	y -= mini
	ans = 2 * mini + mini
	mini = y // 2
	if mini > x:
		mini = x
	x -= mini
	ans += 2 * mini + mini
	print(ans)


t = int(input(''))
a = []
b = []
c = []
for i in range(t):
	values = input('').split()
	abc = [int(x) for x in values]
	a.append(abc[0])
	b.append(abc[1])
	c.append(abc[2])
for i in range(t):
	maxValue = 0
	maxfromC = 0
	maxfromB = 0
	if c[i] >= 2 and b[i] >= 1:
		maxfromC = c[i] // 2
		if maxfromC >= b[i]:
			maxfromC = b[i]
		maxValue += 2 * maxfromC + maxfromC
	if b[i] >= 2 and a[i] >= 1:
		maxfromB = (b[i] - maxfromC) // 2
		if maxfromB >= a[i]:
			maxfromB = a[i]
		maxValue += 2 * maxfromB + maxfromB
	print(maxValue)


mod = 10 ** 9 + 7
from sys import stdin, stdout
import bisect
import sys
sys.setrecursionlimit(10 ** 6)
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
import collections
import math
import heapq
from random import randint as rn

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	t = inin()
	for _ in range(t):
		(x, y, z) = cin()
		ans = 0
		p = z // 2
		ans += min(p, y)
		y = y - p
		y = max(y, 0)
		p = y // 2
		ans += min(x, p)
		print(ans * 3)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


def func(a, b, c):
	sum = 0
	val_c = c // 2
	if b >= val_c:
		b = b - val_c
		sum += 3 * val_c
	else:
		sum += 3 * b
		c = c - 2 * b
		b = 0
	val_b = b // 2
	if a >= val_b:
		a = a - val_b
		sum += 3 * val_b
	else:
		sum += 3 * a
		b = b - 2 * a
		a = 0
	return sum
t = int(input())
ans = []
for i in range(t):
	(a, b, c) = (int(i) for i in input().split())
	ans.append(func(a, b, c))
for i in ans:
	print(i)


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import math
t = ii()
for i in range(t):
	(a, b, c) = mi()
	ans = 0
	while c >= 2 and b >= 1:
		b -= 1
		c -= 2
		ans += 3
	while a >= 1 and b >= 2:
		a -= 1
		b -= 2
		ans += 3
	print(ans)


l = []
for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	s = 0
	while 1:
		if b >= 1 and c >= 2:
			s += 3
			b = b - 1
			c = c - 2
		else:
			break
	while 1:
		if a >= 1 and b >= 2:
			s += 3
			a = a - 1
			b = b - 2
		else:
			break
	l.append(s)
print(*l, sep='\n')


for _ in range(int(input())):
	(p, q, r) = map(int, input().split())
	c = 0
	while 1:
		if r >= 2 and q >= 1:
			r = r - 2
			q = q - 1
			c = c + 3
		else:
			break
	while 1:
		if q >= 2 and p >= 1:
			q = q - 2
			p = p - 1
			c = c + 3
		else:
			break
	print(c)


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
for _ in range(int(input())):
	a = [int(x) for x in input().split()]
	print(min(a[1], a[2] // 2) * 3 + min((a[1] - min(a[1], a[2] // 2)) // 2, a[0]) * 3)


T = int(input())
for _ in range(T):
	(a, b, c) = map(int, input().split())
	res = min(c - int(c % 2 > 0), b * 2)
	rest_b = min(b, res // 2)
	second = min(b - rest_b - int((b - rest_b) % 2 > 0), a * 2)
	res += rest_b + second + second // 2
	print(res)


for _ in range(int(input().strip())):
	(a, b, c) = map(int, input().strip().split())
	if b <= 1 and c <= 1:
		print(str(0))
	elif b == 0:
		print(str(0))
	else:
		j = b
		x = 3 * min(b, c // 2)
		j -= min(b, c // 2)
		x += 3 * min(a, j // 2)
		print(str(x))


t = int(input())
while t:
	t -= 1
	(a, b, c) = map(int, input().split())
	ans = 0
	d = min(c - c % 2, 2 * b)
	ans += d + d // 2
	b -= d // 2
	d = min(b - b % 2, 2 * a)
	ans += d + d // 2
	print(ans)


import os
import heapq
import sys
import math
from collections import defaultdict
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(a, b, c) = map(int, input().split())
		if c // 2 >= b:
			print(b + b * 2)
		else:
			ans = 0
			ans += c // 2 + c // 2 * 2
			rem = b - c // 2
			if rem // 2 >= a:
				ans += a + a * 2
			else:
				ans += rem // 2 + rem // 2 * 2
			print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


try:
	n = int(input())
	for i in range(n):
		(a, b, c) = map(int, input().split())
		if b == 0:
			print(0)
		else:
			ans = min(c // 2, b)
			b -= ans
			ans += 2 * ans
			x = min(b // 2, a)
			x += 2 * x
			ans += x
			print(ans)
except:
	pass


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	if b == 0:
		print(0)
		continue
	cnt = 0
	br = c // 2
	if br > b:
		cnt = b + b * 2
		b = 0
	else:
		cnt = br + br * 2
		b -= br
	if b > 0:
		ar = b // 2
		if ar > a:
			cnt += a + a * 2
			a = 0
		else:
			cnt += ar + ar * 2
			a -= ar
	print(cnt)


read = lambda : [int(i) for i in input().split()]
t = int(input())
for _ in range(t):
	(a, b, c) = read()
	k = min(a, b // 2)
	a -= k
	b -= 2 * k
	l = min(b, c // 2)
	ans1 = 3 * k + 3 * l
	a += k
	b += 2 * k
	k = min(b, c // 2)
	b -= k
	c -= 2 * k
	l = min(a, b // 2)
	ans2 = 3 * k + 3 * l
	print(max(ans1, ans2))


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	count = 0
	while c != 0:
		if b >= 1 and c >= 2:
			count += 3
		else:
			break
		b -= 1
		c -= 2
	while a != 0:
		if b >= 2 and a >= 1:
			count += 3
		else:
			break
		b -= 2
		a -= 1
	print(count)


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


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


d = int(input())
for _ in range(d):
	(a, b, c) = [int(x) for x in input().split()]
	t = min(c // 2, b)
	t = t + min((b - t) // 2, a)
	print(t * 3)


import sys

def In():
	return sys.stdin.readline()

def Out(x):
	return sys.stdout.write(str(x) + '\n')

def Solve(arr):
	count = 0
	obj1 = min(arr[1], arr[2] // 2)
	count += obj1 * 3
	arr[1] = arr[1] - obj1
	arr[2] = arr[2] - obj1 * 2
	obj2 = min(arr[0], arr[1] // 2)
	count += obj2 * 3
	arr[0] = arr[0] - obj2
	arr[1] = arr[1] - obj2 * 2
	return count
t = int(In())
for i in range(t):
	arr = list(map(int, In().split()))
	Out(Solve(arr))


answer = []
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	stones = 0
	cc = c // 2
	if b > cc:
		stones += cc * 3
		b -= cc
	else:
		stones += b * 3
		b = 0
	bb = b // 2
	if a > bb:
		stones += bb * 3
	else:
		stones += a * 3
	answer.append(stones)
for ans in answer:
	print(ans)


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


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


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


(T, *ABC) = map(int, open(0).read().split())
for (a, b, c) in zip(*[iter(ABC)] * 3):
	ans = 0
	for x in range(a + 1):
		for y in range(c // 2 + 1):
			if 2 * x + y <= b:
				ans = max(ans, 3 * (x + y))
	print(ans)


for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	p = 0
	if y == 0 or (x == 0 and z == 0):
		print('0')
	else:
		if z // 2 <= y:
			p = z // 2 * 2 + z // 2 + p
			y = y - z // 2
			z = 0
		elif z // 2 > y:
			p = p + y + y * 2
			print(p)
			continue
		if y // 2 <= x:
			p = p + y // 2 * 2 + y // 2
			x = x - y // 2
			y == 0
		elif y // 2 > x:
			p = p + x + x * 2
			print(p)
			continue
		print(p)


n = int(input())
for _ in range(n):
	s = 0
	(a, b, c) = list(map(int, input().split()))
	nc = c // 2
	if b >= nc:
		s += nc
	else:
		s += b
	b -= nc
	if b >= 2:
		bc = b // 2
		if a >= bc:
			s += bc
		else:
			s += a
	print(s * 3)


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


import os
import sys
from math import *
from collections import *
from fractions import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
M = 998244353
EPS = 1e-06

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(a, b, c) = value()
	first = min(a, b // 2)
	ans = 0
	for i in range(first + 1):
		here_a = a - i
		here_b = b - 2 * i
		second = min(here_b, c // 2)
		here_b -= second
		here_c = c - 2 * second
		ans = max(ans, a + b + c - here_a - here_b - here_c)
	print(ans)


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


for m in range(int(input())):
	abc = list(map(int, input().split()))
	stones = 0
	if abc[1] >= 1:
		if abc[2] >= 2 and abc[1] >= 1:
			stones += 3 * min(abc[2] // 2, abc[1])
			abc[2] -= min(abc[2] // 2, abc[1]) * 2
			abc[1] -= stones // 3
		if abc[1] >= 2 and abc[0] >= 1:
			stones += 3 * min(abc[1] // 2, abc[0])
	print(stones)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if b == 0:
		print(0)
	else:
		count = 0
		for j in range(100):
			if c >= 2 and b >= 1:
				c = c - 2
				b = b - 1
				count = count + 3
			elif b >= 2 and a >= 1:
				b = b - 2
				a = a - 1
				count = count + 3
		print(count)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	k0 = min(a, b // 2)
	l0 = min(b - k0 * 2, c // 2)
	k1 = min(b, c // 2)
	l1 = min(a, (b - k1) // 2)
	print(max(k0 + l0, k1 + l1) * 3)


def main():
	t = int(input())
	for _ in range(t):
		(a, b, c) = [int(i) for i in input().split(' ')]
		res = 0
		for i in range(b, 0, -1):
			if b > 0:
				if c > 1:
					c -= 2
					b -= 1
					res += 3
				elif a != 0 and b >= 2:
					b -= 2
					a -= 1
					res += 3
				else:
					break
			else:
				break
		print(res)
main()


for i in range(int(input())):
	count = 0
	(a, b, c) = map(int, input().split())
	c = c // 2
	if c > 0 and b > 0:
		count = count + min(c, b) * 3
		b = b - min(c, b)
	if b > 1 and a > 0:
		b = b // 2
		count = count + min(a, b) * 3
	print(count)


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
for _ in range(int(z())):
	(a, b, c) = map(int, z().split())
	x = min(b, c // 2)
	y = min(a, (b - x) // 2)
	print((x + y) * 3)


q = int(input())
for _ in range(q):
	l = list(map(int, input().split()))
	s = 0
	while 1:
		if l[1] > 0 and l[2] > 1:
			s += 3
			l[1] -= 1
			l[2] -= 2
		elif l[0] > 0 and l[1] > 1:
			s += 3
			l[0] -= 1
			l[1] -= 2
		else:
			break
	print(s)


def kamni(x, y):
	ky = y // 2
	kx = x
	q = min(ky, kx)
	return q
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	r = kamni(b, c)
	b = b - r
	l = kamni(a, b)
	print(int((l + r) * 3))


n = int(input())
for i in range(n):
	(a, b, c) = [int(x) for x in input().split()]
	count = 0
	count += min(b, c // 2)
	count += min(a, (b - count) // 2)
	print(count * 3)


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


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import *
(t,) = I()
while t:
	t -= 1
	(a, b, c) = I()
	ans = 0
	while b > 0:
		if c > 1:
			ans += 3
			b -= 1
			c -= 2
		elif b >= 2 and a:
			ans += 3
			a -= 1
			b -= 2
		else:
			break
	print(ans)


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


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().strip().split())
	su = 0
	while b != 0:
		if c >= 2:
			su += 3
			c = c - 2
			b = b - 1
		else:
			break
	while a != 0:
		if b >= 2:
			su += 3
			b = b - 2
			a = a - 1
		else:
			break
	print(su)


import re
import math
i = 0
j = 0
k = 0
s = 0
arr1 = []
arr2 = []
arr3 = []
n = int(input())
while j < n:
	s = 0
	i = 0
	arr = input()
	arr1 = re.split(' ', arr)
	for i in range(3):
		arr1[i] = int(arr1[i])
	while arr1[1] > 0 and arr1[2] > 1:
		s += 3
		arr1[1] -= 1
		arr1[2] -= 2
	while arr1[1] > 1 and arr1[0] > 0:
		s += 3
		arr1[1] -= 2
		arr1[0] -= 1
	print(s)
	j += 1


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


n = int(input())
for i in range(n):
	a = list(map(int, input().split()))
	count = 0
	c = []
	c.append(a[0])
	c.append(a[1])
	c.append(a[2])
	a[0] = [a[0], 0]
	a[1] = [a[1], 1]
	a[2] = [a[2], 2]
	a.sort(key=lambda x: x[0], reverse=True)
	if c[1] >= 1 and c[2] >= 2:
		d = int(c[2] / 2)
		if d <= c[1]:
			count = count + d + d * 2
			c[1] = c[1] - d
			c[2] = c[2] - d * 2
		else:
			d = c[1]
			count = count + d + d * 2
			c[1] = 0
			c[2] = c[2] - d * 2
	if c[0] >= 1 and c[1] >= 2:
		d = int(c[1] / 2)
		if d <= c[0]:
			count = count + d + d * 2
			c[0] = c[0] - d
			c[1] = c[1] - d * 2
		else:
			d = c[0]
			count = count + d + d * 2
			c[0] = 0
			c[1] = c[1] - d * 2
	print(count)


from sys import stdin
n = int(stdin.readline().strip())
for i in range(n):
	(a, b, c) = 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)


n = int(input())
p = []
for i in range(0, n):
	(a, b, c) = map(int, input().split())
	f1 = c // 2
	ans = 0
	if b <= f1:
		ans += b * 3
		p.append(str(ans))
	else:
		ans += f1 * 3
		b -= f1
		d2 = b // 2
		if d2 >= a:
			ans += a * 3
		else:
			ans += d2 * 3
		p.append(str(ans))
print('\n'.join(p))


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


n = int(input())
x = 0
res_list = []
while x < n:
	x += 1
	list_of_numbers = list(map(int, input().split()))
	counter = 0
	while list_of_numbers[1] and list_of_numbers[2] and (list_of_numbers[2] != 1):
		counter += 3
		list_of_numbers[1] -= 1
		list_of_numbers[2] -= 2
	while list_of_numbers[0] and list_of_numbers[1] and (list_of_numbers[1] != 1):
		counter += 3
		list_of_numbers[0] -= 1
		list_of_numbers[1] -= 2
	res_list.append(counter)
print('\n'.join(map(str, res_list)))


import math
import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 6)
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	input = sys.stdin.readline

def takeInput():
	return [int(x) for x in input().strip().split()]
t = int(input())
while t != 0:
	t -= 1
	(a, b, c) = takeInput()
	stones1 = 0
	stones2 = 0
	while b != 0 and c >= 2:
		c -= 2
		b -= 1
		stones1 += 3
	while a != 0 and b >= 2:
		b -= 2
		a -= 1
		stones1 += 3
	while a != 0 and b >= 2:
		b -= 2
		a -= 1
		stones2 += 3
	while b != 0 and c >= 2:
		c -= 2
		b -= 1
		stones2 += 3
	print(max(stones1, stones2))


t = int(input())
for a in range(1, t + 1):
	n = 0
	(a, b, c) = [int(x) for x in input().split()]
	if b != 0:
		while c >= 2 and b >= 1:
			c = c - 2
			b = b - 1
			n = n + 3
		while b >= 2 and a >= 1:
			b = b - 2
			a = a - 1
			n = n + 3
		print(n)
	else:
		print(n)


def main():
	scan = input
	integer = int
	array = list
	loop = map
	test_case = integer(scan())
	answer = []
	for i in range(test_case):
		result = 0
		stones = array(loop(integer, scan().split()))
		if stones[1] >= 1 and stones[2] >= 2:
			while True:
				result += 3
				stones[1] -= 1
				stones[2] -= 2
				if stones[1] == 0 or stones[2] <= 1:
					break
		if stones[0] >= 1 and stones[1] >= 2:
			while True:
				result += 3
				stones[0] -= 1
				stones[1] -= 2
				if stones[0] == 0 or stones[1] <= 1:
					break
		answer.append(result)
	for i in answer:
		print(i)
main()


p = int(input())
t = []
for _ in ' ' * p:
	(a, b, c) = map(int, input().split())
	d = min(c // 2, b)
	r = d * 2 + d
	b -= d
	f = min(b // 2, a)
	r += f * 2 + f
	t += [r]
for i in t:
	print(i)


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


query = int(input())
for _ in range(query):
	(a, b, c) = map(int, input().split())
	s = 0
	if b == 0:
		print(s)
	else:
		if c >= 2 * b:
			s += b + 2 * b
		else:
			s += c // 2 * 2 + c // 2
			b -= c // 2
			if b >= 2 * a:
				s += a + a * 2
			else:
				s += b // 2 + b // 2 * 2
		print(s)


for _ in range(int(input())):
	(a, b, c) = list(map(int, input().split()))
	ans = 0
	while True:
		if b >= 1 and c >= 2:
			b -= 1
			c -= 2
			ans += 3
		elif a >= 1 and b >= 2:
			a -= 1
			b -= 2
			ans += 3
		else:
			break
	print(ans)


n = int(input())
for i in range(n):
	s = 0
	(a, b, c) = [int(x) for x in input().split()]
	while b > 0 and c > 1:
		s += 3
		c -= 2
		b -= 1
	while a > 0 and b > 1:
		s += 3
		b -= 2
		a -= 1
	print(s)


def counts(x, y, balls_count):
	q = y // 2
	if x >= q:
		balls_count += q * 3
		x -= q
	else:
		balls_count += x * 3
		x = 0
	return (x, y, balls_count)
t = int(input())
while t:
	balls = [int(i) for i in input().split()]
	balls_count = 0
	(a, b, c) = balls
	if b == 0:
		print(0)
	else:
		(b, c, balls_count) = counts(b, c, balls_count)
		(a, b, balls_count) = counts(a, b, balls_count)
		print(balls_count)
	t -= 1


t = int(input())
for i in range(t):
	stones = list(map(int, input().split(' ')))
	total = sum(stones)
	third = min(stones[2] // 2, stones[1])
	stones[2] -= third * 2
	stones[1] -= third
	second = min(stones[1] // 2, stones[0])
	stones[1] -= second * 2
	stones[0] -= second
	total -= sum(stones)
	print(total)


from collections import defaultdict
from math import ceil
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	total = min(c // 2, b) * 3
	b -= total // 3
	total += min(b // 2, a) * 3
	print(total)


def stones(a, b, c):
	stone_count = 0
	first_take = min(b, c // 2)
	stone_count += 3 * first_take
	b -= first_take
	second_take = min(a, b // 2)
	return stone_count + 3 * second_take
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	print(stones(a, b, c))


t = int(input())
for i in range(0, t):
	a = list(map(int, input().split()))
	total = 0
	if a[2] >= 2:
		if a[2] // 2 <= a[1]:
			total = total + a[2] // 2
			a[1] = a[1] - a[2] // 2
		else:
			total = a[1]
			a[1] = 0
	if a[1] >= 2 and a[0] >= 1:
		if a[1] // 2 <= a[0]:
			total = total + a[1] // 2
		else:
			total = total + a[0]
	print(total * 3)


n = int(input())
for i in range(n):
	(a, b, c) = tuple(map(int, input().split()))
	t1 = 0
	d = min(a, b // 2)
	b1 = b - 2 * d
	t1 += 3 * d
	d = min(b1, c // 2)
	t1 += 3 * d
	t2 = 0
	d = min(b, c // 2)
	t2 += 3 * d
	b1 = b - d
	d = min(a, b1 // 2)
	t2 += 3 * d
	print(t1 if t1 >= t2 else t2)


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	x = min(c // 2, b)
	b -= x
	y = min(b // 2, a)
	print((x + y) * 3)
	t -= 1


n = int(input())
for i in range(n):
	result = 0
	(a, b, c) = list(map(int, input().split()))
	first = c // 2
	firsttt = min(b, first)
	result += firsttt * 2 + firsttt
	b -= firsttt
	second = b // 2
	secondtt = min(a, second)
	result += secondtt * 2 + secondtt
	print(result)


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


t = int(input())
while t:
	(a, b, c) = map(int, input().split())
	if b != 0:
		z1 = c // 2
		c1 = min(z1, b)
		c2 = b - c1
		z2 = c2 // 2
		c3 = min(a, z2)
		ans1 = c1 * 1 + c1 * 2 + c3 * 1 + c3 * 2
		z3 = b // 2
		c4 = min(z3, a)
		c5 = b - c4 * 2
		z4 = c // 2
		c6 = min(z4, c5)
		ans2 = c4 * 1 + c4 * 2 + c6 * 1 + c6 * 2
		print(max(ans1, ans2))
	else:
		print(0)
	t = t - 1


T = int(input())
query = []
for i in range(T):
	(a, b, c) = map(int, input().split())
	query.append((a, b, c))

def solve(a, b, c, ans=0):
	x = min(a // 1, b // 2)
	y = min(b // 1, c // 2)
	if x == 0 and y == 0:
		return ans
	elif x >= y:
		return solve(a - 1, b - 2, c, ans + 3)
	else:
		return solve(a, b - 1, c - 2, ans + 3)
for i in range(T):
	(a, b, c) = query[i]
	print(solve(a, b, c, ans=0))


t = int(input())
for i in range(t):
	sum = 0
	a = list(map(int, input().split()))
	while a[1] >= 1 and a[2] >= 2:
		sum = sum + 3
		a[1] = a[1] - 1
		a[2] = a[2] - 2
	while a[0] >= 1 and a[1] >= 2:
		sum = sum + 3
		a[0] = a[0] - 1
		a[1] = a[1] - 2
	print(sum)


a = int(input())
for i in range(a):
	l = list(map(int, input().split()))
	n = 3 * min(l[2] // 2, l[1])
	l[1] = l[1] - min(l[2] // 2, l[1])
	n = n + 3 * min(l[1] // 2, l[0])
	print(n)


for _ in range(int(input())):
	s = 0
	l = list(map(int, input().split()))
	while l[1] < int(l[2] / 2):
		l[2] -= 2
	s = int(l[2] / 2) * 3
	l[1] = l[1] - int(l[2] / 2)
	while l[0] < int(l[1] / 2):
		l[1] -= 2
	s += int(l[1] / 2) * 3
	print(int(s))


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	x = a
	y = b
	z = c
	s1 = 0
	s2 = 0
	while a >= 1 and b >= 2:
		s1 = s1 + 3
		a = a - 1
		b = b - 2
	while c >= 2 and b >= 1:
		s1 = s1 + 3
		c = c - 2
		b = b - 1
	a = x
	b = y
	c = z
	while c >= 2 and b >= 1:
		s2 = s2 + 3
		c = c - 2
		b = b - 1
	while a >= 1 and b >= 2:
		s2 = s2 + 3
		a = a - 1
		b = b - 2
	if s1 > s2:
		print(s1)
	else:
		print(s2)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	x = 0
	if c // 2 > 0 and b >= 1:
		for j in range(c // 2):
			if b == 0:
				break
			x += 3
			b -= 1
	if b // 2 > 0 and a >= 1:
		for j in range(b // 2):
			if a == 0:
				break
			x += 3
			a -= 1
	print(x)


def ab():
	(a, b, c) = list(map(int, input().split()))
	sum = a + b + c
	while True:
		if c >= 2 and b >= 1:
			c = c - 2
			b = b - 1
		else:
			break
	while True:
		if a >= 1 and b >= 2:
			a = a - 1
			b = b - 2
		else:
			break
	sumf = a + b + c
	print(sum - sumf)
n = input()
for i in range(0, int(n)):
	ab()


for _ in range(int(input())):
	(a, b, c) = [int(x) for x in input().split()]
	n2 = b
	n1 = a
	n3 = c
	sm1 = 0
	while n1 * 2 > n2:
		n1 -= 1
	sm1 += n1 + n1 * 2
	n2 -= n1 * 2
	while n2 * 2 > n3:
		n2 -= 1
	sm1 += n2 + n2 * 2
	sm2 = 0
	n2 = b
	n1 = a
	n3 = c
	while n2 * 2 > n3:
		n2 -= 1
	sm2 = n2 + n2 * 2
	n2 = b - n2
	while n1 * 2 > n2:
		n1 -= 1
	sm2 += n1 + n1 * 2
	print(max(sm1, sm2))


t = int(input())
for i in range(0, t, 1):
	(a, b, c) = map(int, input().split())
	r = 0
	for j in range(0, 100, 1):
		aa = min(j, a, b // 2)
		bb = min(b - aa * 2, c // 2)
		r = max(r, aa * 3 + bb * 3)
	print(r)


t = int(input())
for i in range(t):
	s = 0
	(a, b, c) = [int(j) for j in input().split()]
	p = min(b, c // 2)
	s = s + 3 * p
	b = b - p
	c = c - p * 2
	q = min(a, b // 2)
	s = s + 3 * q
	print(s)


tests = int(input())
for i in range(tests):
	(a, b, c) = map(int, input().split())
	stones = 0
	fromBC = min(b, c // 2) * 3
	stones += fromBC
	b -= fromBC // 3
	fromAB = min(a, b // 2) * 3
	stones += fromAB
	print(stones)


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


n = int(input())
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	s = 0
	if b - c // 2 < 0:
		print(b * 3)
		continue
	s += c // 2 * 3
	b -= c // 2
	if a > b // 2:
		s += b // 2 * 3
	else:
		s += a * 3
	print(s)


t = int(input())
for query in range(t):
	(a, b, c) = 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)


import math

def init():
	t = int(input())
	for i in range(t):
		(h1, h2, h3) = map(lambda x: int(x), input().split(' '))
		count = 0
		second_move_count = min(h2, math.floor(h3 / 2))
		count += 3 * second_move_count
		h2 -= second_move_count
		first_move_count = min(h1, math.floor(h2 / 2))
		count += 3 * first_move_count
		print(count)
init()


from sys import stdin, stdout
import collections
import heapq
import itertools
import functools
import math
import operator
import string
ALPHABET = string.ascii_lowercase
DIGITS = string.digits

def read_line():
	return stdin.readline().strip()

def read_int():
	return int(read_line())

def read_arr():
	return read_line().split(' ')

def read_int_arr():
	return [int(x) for x in read_arr()]

def query_interactive(s):
	print(s)
	stdout.flush()

def solve():
	(a, b, c) = read_int_arr()
	f = min(a, b // 2)
	g = min(b, c // 2)
	res = max(f * 3 + min(b - f * 2, c // 2) * 3, g * 3 + min(a, (b - g) // 2) * 3)
	print(res)

def main():
	T = 1
	T = read_int()
	for _ in range(T):
		solve()
main()


def a1(a, b, c, k):
	while a >= 1 and b >= 2:
		k = k + 3
		a = a - 1
		b = b - 2
	while b >= 1 and c >= 2:
		k = k + 3
		b = b - 1
		c = c - 2
	return k

def a2(a, b, c, l):
	while b >= 1 and c >= 2:
		l = l + 3
		b = b - 1
		c = c - 2
	while a >= 1 and b >= 2:
		l = l + 3
		a = a - 1
		b = b - 2
	return l
t = int(input())
while t > 0:
	t = t - 1
	(a, b, c) = map(int, input().split())
	k = 0
	l = 0
	print(max(a1(a, b, c, k), a2(a, b, c, l)))


for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	print(min(x, (y - min(y, z // 2)) // 2) * 3 + min(y, z // 2) * 3)


import random

def get_many_ints():
	return map(int, input().split())

def get_int():
	return int(input())
t = get_int()
for _ in range(t):
	(a, b, c) = get_many_ints()
	best = 0
	for i in range(100):
		for j in range(100):
			if a >= i and b >= 2 * i + j and (c >= 2 * j):
				best = max(best, i + j)
	print(3 * best)


n = int(input())
for i in range(n):
	sum = 0
	(a, b, c) = map(int, input().split())
	(a1, b1, c1) = (a, b, c)
	while c > 1 and b > 0:
		sum += 3
		c -= 2
		b -= 1
	while b > 1 and a > 0:
		sum += 3
		b -= 2
		a -= 1
	print(sum)


def op1(stone, alice):
	stone[0] -= 1
	stone[1] -= 2
	alice += 3
	return (stone, alice)

def op2(stone, alice):
	stone[1] -= 1
	stone[2] -= 2
	alice += 3
	return (stone, alice)
for _ in range(int(input())):
	alice = 0
	stones = list(map(int, input().split()))
	while stones[1] > 0 and stones[2] > 1:
		(stones, alice) = op2(stones, alice)
	while stones[0] > 0 and stones[1] > 1:
		(stones, alice) = op1(stones, alice)
	print(alice)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	sum = 0
	if 2 * b < c:
		sum += b + 2 * b
	else:
		if c % 2 == 0:
			sum += c
			sum += c // 2
			b = b - c // 2
		else:
			sum += c - 1
			sum += (c - 1) // 2
			b = b - (c - 1) // 2
		if 2 * a < b:
			sum += a + 2 * a
		elif b % 2 == 0:
			sum += b
			sum += b // 2
		else:
			sum += b - 1
			sum += (b - 1) // 2
	print(sum)


def solve(a, b, c):
	if b == 0 or max(a, b, c) == 1:
		return 0
	cnt = 0
	while True:
		if b >= 1 and c >= 2:
			b -= 1
			c -= 2
			cnt += 3
		elif a >= 1 and b >= 2:
			a -= 1
			b -= 2
			cnt += 3
		else:
			return cnt
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	print(solve(a, b, c))


import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	resl = 0
	if b >= c // 2:
		resl += c // 2 * 3
		b -= c // 2
	else:
		resl += b * 3
		b = 0
	if a >= b // 2:
		resl += b // 2 * 3
	else:
		resl += a * 3
	resr = 0
	if a >= b // 2:
		resr += b // 2 * 3
		b = b % 2
	else:
		resr += a * 3
		a = 0
	if b >= c // 2:
		resr += c // 2 * 3
	else:
		resr += b * 3
	print(max(resl, resr))


from sys import stdin
r = stdin.readline

def main():
	cases = int(r())
	for case in range(cases):
		(a, b, c) = map(int, r().strip().split())
		ans = 0
		mult = min(c // 2, b)
		if b != 0:
			ans += mult * 2 + mult
		b -= mult
		mult = min(b // 2, a)
		if a != 0:
			ans += mult * 2 + mult
		print(ans)
main()


t = int(input())
while t:
	(a, b, c) = map(int, input().split(' '))
	r1 = min(a, b // 2)
	r2 = min(b, c // 2)
	a1 = r1 * 3 + min(b - r1 * 2, c // 2) * 3
	a2 = r2 * 3 + min((b - r2) // 2, a) * 3
	print(max(a1, a2))
	t -= 1


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	val = c // 2
	ans = 0
	if b >= val:
		b -= val
		c -= val * 2
		ans += val * 2 + val
	else:
		ans += 3 * b
		c -= 2 * b
		b = 0
	if b != 0:
		val1 = b // 2
		if a >= val1:
			a -= val1
			b -= val1 * 2
			ans += val1 * 3
		else:
			ans += 3 * a
			b -= 2 * a
			a = 0
	print(ans)


def func(a, b, c):
	m = min(b, (c - c % 2) / 2)
	if m == b:
		return int(3 * m)
	else:
		b = b - m
		n = min(a, (b - b % 2) / 2)
		return int(3 * (m + n))
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	ans = func(a, b, c)
	print(ans)


a = int(input())
r = 0
x = list()
while r < a:
	d = 0
	c = [int(c) for c in input().split()]
	while True:
		if c[2] >= 2 and c[1] >= 1:
			c[2] = c[2] - 2
			c[1] = c[1] - 1
			d = d + 3
		elif c[1] >= 2 and c[0] >= 1:
			c[1] = c[1] - 2
			c[0] = c[0] - 1
			d = d + 3
		else:
			break
	r = r + 1
	x.append(d)
r = 0
while r < a:
	print(x[r])
	r = r + 1


for t in range(int(input())):
	(a, b, c) = list(map(int, input().split()))
	s1 = 0
	(a1, b1, c1) = (a, b, c)
	if a1 >= b1 // 2:
		s1 += b1 // 2 + 2 * (b1 // 2)
		b1 -= 2 * (b1 // 2)
	elif a1 > 0:
		s1 += a1 + 2 * a1
		b1 -= 2 * a1
	if b1 >= c1 // 2:
		s1 += c1 // 2 + 2 * (c1 // 2)
	elif b1 > 0:
		s1 += b1 + 2 * b1
	(a2, b2, c2) = (a, b, c)
	s2 = 0
	if b2 >= c2 // 2:
		s2 += c2 // 2 + 2 * (c2 // 2)
		b2 -= c2 // 2
	elif b2 > 0:
		s2 += b2 + 2 * b2
		b2 -= b2
	if a2 >= b2 // 2:
		s2 += b2 // 2 + 2 * (b2 // 2)
	elif a2 > 0:
		s2 += 3 * a2
	print(max(s1, s2))


n = int(input())
s = list()
for x in range(n):
	s.append(input())
for x in s:
	r = 0
	x = x.split()
	a = int(x[0])
	b = int(x[1])
	c = int(x[2])
	k = min(b, c // 2)
	c -= k * 2
	b -= k
	r += k * 3
	k = min(a, b // 2)
	b -= k * 2
	a -= k
	r += k * 3
	print(r)


t = int(input(''))
L = []
for i in range(t):
	values = input('')
	L.append(values)

def stones(stone):
	stone = stone.split()
	abc = []
	for i in stone:
		abc.append(int(i))
	max = 0
	while abc[1] >= 1 and abc[2] >= 2:
		max = max + 3
		abc[1] -= 1
		abc[2] -= 2
	while abc[0] >= 1 and abc[1] >= 2:
		max = max + 3
		abc[0] -= 1
		abc[1] -= 2
	return max
for i in range(t):
	print(stones(L[i]))


t = int(input())
while t > 0:
	t = t - 1
	(a, b, c) = map(int, input().split())
	stones1 = 0
	stones2 = 0
	while c >= 2 and b >= 1:
		c = c - 2
		b = b - 1
		stones1 += 3
	while b >= 2 and a >= 1:
		b -= 2
		a -= 1
		stones1 += 3
	while b >= 2 and a >= 1:
		b -= 2
		a -= 1
		stones2 += 3
	while c >= 2 and b >= 1:
		c = c - 2
		b = b - 1
		stones2 += 3
	print(max(stones1, stones2))


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


for _ in range(int(input())):
	(x, y, z) = 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)


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


num_cases = int(input())
for case in range(num_cases):
	stones = [int(x) for x in input().split()]
	res = 0
	third = min(stones[1], int(stones[2] / 2))
	res += third * 3
	stones[1] -= third
	stones[2] -= third * 2
	second = min(stones[0], int(stones[1] / 2))
	res += second * 3
	print(res)


for _ in range(int(input())):
	(a, b, c) = list(map(int, input().split()))
	q = a
	w = b
	e = c
	c1 = c // 2
	if b >= c1 and c1 >= 1:
		c -= c1 * 2
		b -= c1
	elif b < c1 and c1 >= 1:
		c -= b * 2
		b = 0
	b1 = b // 2
	if a >= b1 and b1 >= 1:
		b -= b1 * 2
		a -= b1
	elif a < b1 and b1 >= 1:
		b -= a * 2
		a = 0
	print(q - a + w - b + e - c)


t = int(input())
while t:
	heaps = [int(i) for i in input().split(' ')]
	take_2c = int(heaps[2] // 2)
	take_2c = heaps[1] if take_2c > heaps[1] else take_2c
	take_1b = take_2c
	heaps[1] -= take_1b
	take_2b = int(heaps[1] // 2)
	take_2b = heaps[0] if take_2b > heaps[0] else take_2b
	take_1a = take_2b
	print(take_1a + take_1b + take_2b * 2 + take_2c * 2)
	t -= 1


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	total = 0
	(qb, qc) = (0, 0)
	if b == 0:
		print(0)
	elif c == 0:
		qb = min(a, b // 2)
		total = qb * 2 + qb
		print(total)
	elif a == 0:
		qc = min(b, c // 2)
		total = qc * 2 + qc
		print(total)
	else:
		qc = min(b, c // 2)
		b -= qc
		qb = min(a, b // 2)
		total = qc * 2 + qc + qb * 2 + qb
		print(total)


q = int(input())
for i in range(q):
	(a, b, c) = list(map(int, input().split(' ')))
	sum = min(b, c // 2) * 3
	if b - min(b, c // 2) >= 2:
		sum += min(a, (b - min(b, c // 2)) // 2) * 3
	print(sum)


elem = int(input())
for x in range(elem):
	ar = []
	for x in input().split(' '):
		ar.append(int(x))
	count = 0
	while ar[1] > 0:
		if ar[2] > 1:
			count = count + 3
			ar[2] = ar[2] - 2
			ar[1] = ar[1] - 1
		else:
			break
	while ar[0] > 0:
		if ar[1] > 1:
			count = count + 3
			ar[1] = ar[1] - 2
			ar[0] = ar[0] - 1
		else:
			break
	print(count)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	m = 0
	for i in range(a + 1):
		for j in range(b + 1):
			if 2 * i + j <= b and 2 * j <= c:
				m = max(m, 3 * (i + j))
	print(m)


import math

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

def solve():
	[a, b, c] = input_int()
	d = min(c // 2, b)
	e = min(a, (b - d) // 2)
	print((d + e) * 3)
	return
[n] = input_int()
for i in range(0, n):
	solve()


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)))


from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl = lambda : list(map(int, input().split()))
inm = lambda : map(int, input().split())
DBG = True
BIG = 999999999
R = 10 ** 9 + 7

def ddprint(x):
	if DBG:
		print(x)
tt = inn()
for t in range(tt):
	(a, b, c) = inm()
	mx = 0
	for x in range(a + 1):
		if x * 2 > b:
			break
		for y in range(b - 2 * x + 1):
			if y * 2 > c:
				continue
			z = 3 * (x + y)
			if z > mx:
				mx = z
	print(mx)


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


t = int(input())
for tt in range(0, t):
	(a, b, c) = [int(x) for x in input().split()]
	a1 = a
	b1 = b
	c1 = c
	resa = 0
	resb = 0
	while a - 1 >= 0 and b - 2 >= 0:
		a = a - 1
		b = b - 2
		resa += 3
	while b - 1 >= 0 and c - 2 >= 0:
		b = b - 1
		c = c - 2
		resa += 3
	while b1 - 1 >= 0 and c1 - 2 >= 0:
		b1 = b1 - 1
		c1 = c1 - 2
		resb += 3
	while a1 - 1 >= 0 and b1 - 2 >= 0:
		a1 = a1 - 1
		b1 = b1 - 2
		resb += 3
	print(max((resa, resb)))


import math
case = int(input())
for caseNum in range(0, case):
	(a, b, c) = [int(x) for x in input().split()]
	getStone2 = min(b, math.floor(c / 2))
	b -= getStone2
	getStone1 = min(a, math.floor(b / 2))
	print(3 * (getStone1 + getStone2))


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


from sys import stdin
import math
t = int(stdin.readline())
while t:
	(a, b, c) = map(int, stdin.readline().split())
	(a_, b_, c_) = (a, b, c)
	if b == 0 or (a == 0 and c == 0) or (b < 2 and c < 2):
		k = 0
	else:
		p = c // 2
		if b >= p:
			q = p // 2
			k = 3 * p
			b -= p
			m = b // 2
			if a >= m:
				n = m // 2
				k += 3 * m
			else:
				k += 3 * a
		else:
			k = 3 * b
		m = b_ // 2
		if a_ >= m:
			n = m // 2
			k_ = 3 * m
			b_ -= 2 * m
			p = c_ // 2
			if b_ >= p:
				q = p // 2
				k_ += 3 * p
			else:
				k_ += 3 * b_
		else:
			k_ = 3 * a
		k = max(k, k_)
	print(k)
	t -= 1


t = int(input())
for _ in range(t):
	s = 0
	(a, b, c) = map(int, input().split())
	if c >= b * 2:
		s += 3 * b
		b = 0
		c -= 2 * b
	x = c // 2
	if x <= b and c >= 2:
		s += 3 * x
		b -= x
		c -= 2 * x
	if b >= a * 2:
		s += 3 * a
		a = 0
		b -= 2 * a
	y = b // 2
	if y <= a and b >= 2:
		s += 3 * y
		a -= y
		b -= 2 * y
	print(s)


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)


testes = int(input())
for t in range(testes):
	ent = input().split(' ')
	h1 = int(ent[0])
	h2 = int(ent[1])
	h3 = int(ent[2])
	t2 = h3 // 2
	if t2 <= h2:
		h2 -= t2
		h3 -= t2 * 2
	else:
		t2 = h2
		h2 = 0
		h3 -= t2 * 2
	t1 = h2 // 2
	if t1 <= h1:
		h1 -= t1
		h2 -= t1 * 2
	else:
		t1 = h1
		h1 = 0
		h2 -= t1 * 2
	op = t2 + t1
	h1 = int(ent[0])
	h2 = int(ent[1])
	h3 = int(ent[2])
	t1 = h2 // 2
	if t1 <= h1:
		h1 -= t1
		h2 -= t1 * 2
	else:
		t1 = h2
		h1 = 0
		h2 -= t1 * 2
	t2 = h3 // 2
	if t2 <= h2:
		h2 -= t2
		h3 -= t2 * 2
	else:
		t2 = h2
		h2 = 0
		h3 -= t2 * 2
	op2 = t1 + t2
	if op > op2:
		print(op * 3)
	else:
		print(op2 * 3)


n = int(input())
for x in range(n):
	(a, b, c) = list(map(int, input().split()))
	answer = 0
	while True:
		if c >= 2 and b >= 1:
			c -= 2
			b -= 1
			answer += 3
		elif b >= 2 and a >= 1:
			a -= 1
			b -= 2
			answer += 3
		else:
			break
	print(answer)


from math import ceil

def ans(a, b, c):
	an = 0
	if b == 0:
		return 0
	if c // 2 > b:
		return 3 * b
	else:
		b -= c // 2
		an += c // 2 * 3
		return an + ans(0, a, b)
q = int(input())
for i in range(q):
	(a, b, c) = map(int, input().split())
	print(ans(a, b, c))


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


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	if b == 0:
		print(0)
		continue
	temp = c // 2
	if temp >= b and b != 0:
		print(3 * b)
		continue
	ans = 3 * temp
	b = b - temp
	if a == 0:
		print(ans)
		continue
	temp = b // 2
	if temp >= a and a != 0:
		print(ans + 3 * a)
		continue
	print(ans + 3 * temp)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	TotalStones = 0
	if b == 0:
		pass
	else:
		if c != 0:
			while b >= 1 and c >= 2:
				b -= 1
				c -= 2
				TotalStones += 3
		if a != 0:
			while a >= 1 and b >= 2:
				a -= 1
				b -= 2
				TotalStones += 3
	print(TotalStones)


n = int(input())
s = list()
for x in range(n):
	s.append(input())
for x in s:
	r = 0
	x = x.split()
	a = int(x[0])
	b = int(x[1])
	c = int(x[2])
	while c >= 2 and b >= 1:
		c -= 2
		b -= 1
		r += 3
	while b >= 2 and a >= 1:
		b -= 2
		a -= 1
		r += 3
	print(r)


for _ in range(int(input())):
	(a, b, c) = [int(s) for s in input().split()]
	m = 0
	for x in range(a + 1):
		for y in range(c // 2 + 1):
			if 2 * x + y <= b:
				m = max(m, 3 * x + 3 * y)
	print(m)


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


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	count = 0
	ans = 0
	if b == 0:
		print(0)
	else:
		while a >= 1 and b >= 2 or (b >= 1 and c >= 2):
			if b <= c:
				while b >= 1 and c >= 2:
					ans += 3
					b -= 1
					c -= 2
			if count % 2 == 0:
				if a >= 1 and b >= 2:
					ans += 3
					a -= 1
					b -= 2
			elif b >= 1 and c >= 2:
				ans += 3
				b -= 1
				c -= 2
			count += 1
		print(ans)


n = int(input())
for i in range(n):
	val = [int(i) for i in input().split()]
	s1 = min(val[1], val[2] // 2)
	s2 = min(val[0], (val[1] - s1) // 2)
	print(3 * (s1 + s2))


def main():
	t = int(input().strip())
	for i in range(t):
		ans = 0
		inp = input().strip()
		alist = list(map(float, inp.split(' ')))
		a = alist[0]
		b = alist[1]
		c = alist[2]
		x = 0
		y = 0
		x += min(int(b / 2), a) * 3
		remb = b - 2 * min(int(b / 2), a)
		if remb > 0:
			x += min(int(c / 2), remb) * 3
		y += min(int(c / 2), b) * 3
		remb = b - min(int(c / 2), b)
		if remb > 0:
			y += min(int(remb / 2), a) * 3
		ans = max(int(x), int(y))
		print(ans)
main()


import sys
input = sys.stdin.readline

def solve(a, b, c):
	if c >= b >= 1 and c >= 2:
		return 3 + solve(a, b - 1, c - 2)
	elif b >= 2 and a >= 1:
		return 3 + solve(a - 1, b - 2, c)
	elif b >= 1 and c >= 2:
		return 3 + solve(a, b - 1, c - 2)
	else:
		return 0

def main():
	t = int(input())
	for _ in range(t):
		(a, b, c) = [int(x) for x in input().split()]
		print(solve(a, b, c))
main()


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


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


import sys
input = lambda : sys.stdin.readline()
MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : list(map(int, input().split()))
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	(a, b, c) = f()
	ans = 0
	if c > b * 2:
		ans += b + b * 2
		b = 0
	else:
		ans += c // 2 * 2 + c // 2
		b -= c // 2
	if a * 2 > b:
		ans += b // 2 * 2 + b // 2
	else:
		ans += a + a * 2
	print(ans)


t = int(input())
for i in range(0, t):
	an = 0
	(a, b, c) = [int(x) for x in input().split()]
	if c >= b or b >= a or (a >= b and b >= c):
		while c > 1 and b > 0:
			c = c - 2
			b = b - 1
			an = an + 3
		while a > 0 and b > 1:
			a = a - 1
			b = b - 2
			an = an + 3
	else:
		while a > 0 and b > 1:
			a = a - 1
			b = b - 2
			an = an + 3
		while c > 1 and b > 0:
			c = c - 2
			b = b - 1
			an = an + 3
	print(an)


x = lambda : map(int, input().split())
n = int(input())
for __ in range(n):
	k = 0
	a = list(x())
	while a[1] > 0 and a[2] > 1:
		a[1] -= 1
		a[2] -= 2
		k += 3
	while a[0] > 0 and a[1] > 1:
		a[0] -= 1
		a[1] -= 2
		k += 3
	print(k)


def solve(a, b, c):
	ans = 0
	for i in range(110):
		ta = a
		tb = b
		tc = c
		cnt = 0
		if ta >= i and tb >= 2 * i:
			ta -= i
			tb -= 2 * i
			cnt += i
		cnt += min(tb, tc // 2)
		ans = max(ans, cnt * 3)
	return ans

def main():
	t = int(input())
	for _ in range(t):
		(a, b, c) = [int(i) for i in input().split()]
		print(solve(a, b, c))
main()


t = int(input())
for i in range(t):
	l = list(map(int, input().split()))
	c = sum(l)
	a = l[2] // 2
	if l[1] >= a:
		l[1] -= a
		l[2] -= a * 2
	else:
		l[2] = l[2] - l[1] * 2
		l[1] = 0
	a = l[1] // 2
	if l[0] >= a:
		l[0] -= a
		l[1] -= a * 2
	else:
		l[1] = l[1] - l[0] * 2
		l[0] = 0
	print(c - sum(l))


T = int(input())
ans = []
for i in range(T):
	arr = list(map(int, input().split()))
	(a, b, c) = (arr[0], arr[1], arr[2])
	v1 = min(a, b // 2)
	v2 = min(b, c // 2)
	s1 = 0
	s1 += v1 * 3
	b1 = b - v1 * 2
	s1 += min(b1, c // 2) * 3
	s2 = 0
	s2 += v2 * 3
	b2 = b - v2
	s2 += min(a, b2 // 2) * 3
	ans.append(max(s1, s2))
for el in ans:
	print(el)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	cnt = 0
	while True:
		if a == 0:
			cnt += min(b, c // 2) * 3
			break
		if b == 0:
			break
		if c == 0:
			cnt += min(a, b // 2) * 3
			break
		if b == 1 and c == 1:
			break
		if b >= c:
			cnt += 3
			b -= 2
			a -= 1
		else:
			cnt += 3
			b -= 1
			c -= 2
	print(cnt)


t = int(input())
while t > 0:
	stones = 0
	heaps = [int(i) for i in input().split()]
	while heaps[2] > 1 and heaps[1] > 0:
		stones += 3
		heaps[2] -= 2
		heaps[1] -= 1
	while heaps[1] > 1 and heaps[0] > 0:
		stones += 3
		heaps[1] -= 2
		heaps[0] -= 1
	print(stones)
	t -= 1


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	summ = a + b + c
	while b >= 1 and c >= 2:
		b -= 1
		c -= 2
	while a >= 1 and b >= 2:
		a -= 1
		b -= 2
	print(summ - (a + b + c))


c = int(input())
for i in range(c):
	hand = 0
	stones = list(map(int, input().split()))
	while stones[1] > 1 and stones[0] > 0 or (stones[2] > 1 and stones[1] > 0):
		if stones[2] > 1 and stones[1] > 0:
			if stones[1] * 2 >= stones[2]:
				hand += stones[2] // 2
				stones[1] -= stones[2] // 2
				hand += stones[2] // 2 * 2
				stones[2] = stones[2] % 2
			elif stones[1] * 2 <= stones[2]:
				hand += stones[1] * 3
				stones[1] -= stones[1]
		elif stones[1] > 1 and stones[0] > 0:
			if stones[0] * 2 >= stones[1]:
				hand += stones[1] // 2
				stones[0] -= stones[1] // 2
				hand += stones[1] // 2 * 2
				stones[1] = stones[1] % 2
			elif stones[0] * 2 <= stones[1]:
				hand += stones[0] * 3
				stones[0] -= stones[0]
	print(hand)


for _ in range(int(input())):
	(m, n, l) = map(int, input().split())
	i = m
	j = n
	k = l
	c = 0
	t = 0
	while m >= 1 and n >= 2:
		m = m - 1
		n = n - 2
		c += 3
	while n >= 1 and l >= 2:
		n = n - 1
		l = l - 2
		c += 3
	while j >= 1 and k >= 2:
		j = j - 1
		k = k - 2
		t += 3
	while i >= 1 and j >= 2:
		i = i - 1
		j = j - 2
		t += 3
	print(max(t, c))


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def main():
	t = I()
	rr = []
	for _ in range(t):
		(a, b, c) = LI()
		r = min(b, c // 2)
		b -= r
		r += min(a, b // 2)
		rr.append(r * 3)
	return JA(rr, '\n')
print(main())


def mp():
	return map(int, input().split())
t = int(input())
for tt in range(t):
	(a, b, c) = mp()
	cnt = 0
	while a >= 1 and b >= 2 or (b >= 1 and c >= 2):
		if c >= 2:
			b -= 1
			c -= 2
		else:
			a -= 1
			b -= 2
		cnt += 3
	print(cnt)


t = int(input())
for i in range(t):
	d = 0
	(a, b, c) = map(int, input().split())
	(f, s) = (True, True)
	while s:
		if b > 0 and c > 1:
			d += 3
			b -= 1
			c -= 2
		else:
			s = False
	while f:
		if a > 0 and b > 1:
			d += 3
			a -= 1
			b -= 2
		else:
			f = False
	print(d)


t = int(input())
for i in range(t):
	(a, b, c) = [x for x in map(int, input().split())]
	res = 0
	for i in range(a + 1):
		for j in range(c // 2 + 1):
			if i + j <= (a + b + c) // 3 and 2 * i + j <= b:
				res = max(res, (i + j) * 3)
	print(res)


t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = map(int, input().split())
	if b == 0:
		print(0)
		continue
	x = c // 2
	sumi = 0
	if b >= c // 2:
		sumi += 3 * (c // 2)
		b -= c // 2
		sumi += min(a, b // 2) * 3
		print(sumi)
		continue
	else:
		sumi = 3 * b
		print(sumi)


def foo(a, b, c, ans, type):
	if type == 1:
		if min(a, b // 2) == 0:
			return (a, b, c, ans)
		else:
			k = min(a, b // 2)
			a -= k
			b -= 2 * k
			ans += k * 3
			return (a, b, c, ans)
	elif min(b, c // 2) == 0:
		return (a, b, c, ans)
	else:
		k = min(b, c // 2)
		b -= k
		c -= 2 * k
		ans += k * 3
		return (a, b, c, ans)
t = int(input())
for _ in range(t):
	(a, b, c) = tuple(map(int, input().split()))
	(a_1, b_1, c_1, ans_1) = foo(a, b, c, 0, 1)
	(a_1, b_1, c_1, ans_1) = foo(a_1, b_1, c_1, ans_1, 2)
	(a_2, b_2, c_2, ans_2) = foo(a, b, c, 0, 2)
	(a_2, b_2, c_2, ans_2) = foo(a_2, b_2, c_2, ans_2, 1)
	print(max(ans_1, ans_2))


t = int(input())
for i in range(t):
	s = list(map(int, input().split()))
	A = True
	total = 0
	while A:
		if s[2] >= 2 and s[1] >= 1:
			s[2] -= 2
			s[1] -= 1
			total += 3
		elif s[1] >= 2 and s[0] >= 1:
			s[1] -= 2
			s[0] -= 1
			total += 3
		else:
			A = False
	print(total)


from fractions import gcd
from datetime import date, timedelta
from heapq import *
import math
from collections import defaultdict, Counter, deque
import sys
from bisect import *
import itertools
import copy
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7

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


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


def I():
	return map(int, input().split())
for _ in range(int(input())):
	(a, b, c) = I()
	tot = 0
	while b > 0 and c > 1:
		c -= 2
		b -= 1
		tot += 3
	while a > 0 and b > 1:
		b -= 2
		a -= 1
		tot += 3
	print(tot)


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


def solve(a):
	ans = 0
	while a[1] >= 1 and a[2] >= 2:
		a[1] -= 1
		a[2] -= 2
		ans += 3
	while a[0] >= 1 and a[1] >= 2:
		a[0] -= 1
		a[1] -= 2
		ans += 3
	return ans
t = int(input())
for _ in range(t):
	a = [int(i) for i in input().split()]
	print(solve(a))


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


T = int(input())
for epoch in range(T):
	(a, b, c) = map(int, input().split())
	sum = 0
	for i in range(a + 1):
		for j in range(c + 1):
			if j % 2 == 0 and i * 2 + j // 2 <= b:
				sum = max(sum, i + j + i * 2 + j // 2)
	print(sum)


tests = int(input())
for i in range(tests):
	heaps = list(map(int, input().split()))
	heap00 = heap10 = heaps[0]
	heap01 = heap11 = heaps[1]
	heap02 = heap12 = heaps[2]
	stones = []
	stone = 0
	if heap01 != 0:
		k = heap01 // 2
		if k <= heap00 and heap00:
			heap00 -= k
			heap01 -= k * 2
			stone += k * 3
			if heap01 != 0 and heap02 >= 2:
				stone += 3
			stones.append(stone)
		else:
			heap01 -= heap00 * 2
			stone += heap00 * 3
			k = heap02 // 2
			if k <= heap01:
				stone += k * 3
			else:
				stone += heap01 * 3
			stones.append(stone)
	else:
		stones.append(0)
	stone = 0
	if heap11 != 0:
		k = heap12 // 2
		if k <= heap11 and heap11:
			heap11 -= k
			heap12 -= k * 2
			stone += k * 3
			if heap11 != 0 and heap10 >= 2:
				k = heap11 // 2
				if k <= heap10:
					stone += k * 3
			stones.append(stone)
		else:
			stone += heap11 * 3
			stones.append(stone)
	else:
		stones.append(0)
	print(max(stones))


from math import *
from sys import *
from heapq import *
from collections import defaultdict
from itertools import permutations
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def graph_as_tree_1_root():
	n = int(input())
	dict = defaultdict(list)
	for _ in range(n - 1):
		(x, y) = list(map(int, input().split()))
		dict[x].append(y)
		dict[y].append(x)
	tree = [[1]]
	temp = [1]
	vall = 0
	seen = set([i for i in range(2, n + 1)])
	lol = []
	while len(seen) > 0:
		lol = list(seen)
		tt = []
		for x in temp:
			aa = []
			for val in dict[x]:
				if val in seen:
					aa += [val]
					seen.remove(val)
			dict[x] = aa
			tt += aa
		tree.append(tt)
		temp = tt
		vall += 1
	for x in lol:
		dict[x] = []
	print(tree, dict)

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def alldivisors(n):
	list = []
	arr = []
	for i in range(1, int(sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				arr += [i]
			else:
				arr += [i]
				list.append(n // i)
	arr += list[::-1]
	return arr

def primefactorisation(n):
	potentional_p = 3
	itog_list = defaultdict(int)
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			itog_list[n] += 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			itog_list[potentional_p] += 1
		potentional_p += 2
	return itog_list

def main():
	t = int(input())
	for _ in range(t):
		(a, b, c) = list(map(int, input().split()))
		res1 = 3 * min(a, b // 2)
		vall = 3 * min(b - res1 * 2, c // 2)
		if vall >= 0:
			res1 += vall
		res2 = 3 * min(b, c // 2)
		vall = 3 * min((b - res2 // 3) // 2, a)
		if vall >= 0:
			res2 += vall
		print(max(res1, res2))
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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


n = int(input())
for k in range(n):
	(a, b, c) = [int(i) for i in input().split()]
	ans = 0
	if b == 0:
		print(0)
	else:
		if b - c // 2 >= 0:
			ans += c // 2 + 2 * (c // 2)
			b -= c // 2
		else:
			ans += b + 2 * b
			print(ans)
			continue
		if a - b // 2 >= 0:
			ans += b // 2 + 2 * (b // 2)
		else:
			ans += a + 2 * a
		print(ans)


def foo(a, b, c):
	stones = 0
	while b > 0 and c > 1:
		c -= 2
		b -= 1
		stones += 3
	while a > 0 and b > 1:
		b -= 2
		a -= 1
		stones += 3
	return stones
t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	print(foo(a, b, c))
	t -= 1


i = int(input())
for j in range(i):
	stones = 0
	(a, b, c) = [int(k) for k in input().split()]
	while a >= 1 and b >= 2 or (b >= 1 and c >= 2):
		if c >= 2:
			if b >= 1 and c >= 2:
				b -= 1
				c -= 2
				stones += 3
			elif a >= 1 and b >= 2:
				a -= 1
				b -= 2
				stones += 3
		elif a >= 1 and b >= 2:
			a -= 1
			b -= 2
			stones += 3
		elif b >= 1 and c >= 2:
			b -= 1
			c -= 2
			stones += 3
	print(stones)


no_of_test = int(input())
for f in range(no_of_test):
	n = [int(a) for a in input().split()]
	a = n[0]
	b = n[1]
	c = n[2]
	i = 0
	if b > 0:
		if b == c or a == b or a + b > c:
			if c > 2 * b:
				i += b
			else:
				i += c // 2
			b -= i
			if b >= 2 * a:
				i += a
			else:
				i += b // 2
		elif c >= 2 * b:
			i += b
		elif b >= c:
			if b > 2 * a:
				i = a
			else:
				i = b // 2
			b -= 2 * i
			if c >= 2 * b:
				i += b
			else:
				i += c // 2
		else:
			if c > 2 * b:
				i += b
			else:
				i += c // 2
			b -= i
			if b >= 2 * a:
				i += a
			else:
				i += b // 2
	print(3 * i)


t = int(input())
i = 0
while i < t:
	s = 0
	(a, b, c) = map(int, input().split())
	while b > 0:
		if c <= 1:
			break
		s += 3
		b -= 1
		c -= 2
	while a > 0:
		if b <= 1:
			break
		s += 3
		a -= 1
		b -= 2
	print(s)
	i += 1


from sys import stdin

def scal(typ=int):
	return typ(stdin.readline())

def vec(typ=int):
	if isinstance(typ, list):
		inp = stdin.readline().split()
		return [typ[i](inp[i]) for i in range(len(inp))]
	else:
		return list(map(typ, stdin.readline().split()))
t = scal()
for _ in range(t):
	(a, b, c) = vec()
	n = min(b, c // 2)
	b -= n
	n += min(a, b // 2)
	print(3 * n)


t = int(input())
cnt = []
for i in range(t):
	c1 = c2 = 0
	a = [int(x) for x in input().split()]
	b = []
	for j in range(3):
		b.append(a[j])
	while a[0] > 0 and a[1] > 1:
		c1 += 3
		a[0] -= 1
		a[1] -= 2
	while a[1] > 0 and a[2] > 1:
		c1 += 3
		a[1] -= 1
		a[2] -= 2
	while b[1] > 0 and b[2] > 1:
		c2 += 3
		b[1] -= 1
		b[2] -= 2
	while b[0] > 0 and b[1] > 1:
		c2 += 3
		b[0] -= 1
		b[1] -= 2
	cnt.append(max(c1, c2))
for i in range(len(cnt)):
	print(cnt[i])


for _ in [0] * int(input()):
	(a, b, c) = map(int, input().split())
	d = 0
	while b:
		if c > 1:
			d += 3
			b -= 1
			c -= 2
		elif a and b >= 2:
			d += 3
			a -= 1
			b -= 2
		else:
			break
	print(d)


def solve(a, b, c):
	stones = 0
	while c > 1 and b > 0:
		b -= 1
		c -= 2
		stones += 3
	while b > 1 and a > 0:
		a -= 1
		b -= 2
		stones += 3
	print(stones)
	return

def main():
	t = int(input())
	while t:
		t -= 1
		(a, b, c) = (int(i) for i in input().split())
		solve(a, b, c)
	return
main()


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(1000000000.0 + 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)


for i in range(int(input())):
	(a, b, c) = input().split()
	(a, b, c) = (int(a), int(b), int(c))
	count = 0
	dc = c // 2
	if dc > b:
		count += b * 3
		b = b - b
		c = c - 2 * b
	else:
		b = b - dc
		c = c - 2 * dc
		count += dc * 3
	db = b // 2
	if db > a:
		count += a * 3
		a = a - a
		b = b - 2 * a
	else:
		a = a - db
		b = b - 2 * db
		count += db * 3
	print(count)


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


for x in range(int(input())):
	l = list(map(int, input().split()))
	stones = 0
	while l[1] >= 1 and l[-1] >= 2:
		l[1] -= 1
		l[-1] -= 2
		stones += 3
	while l[0] >= 1 and l[1] >= 2:
		l[0] -= 1
		l[1] -= 2
		stones += 3
	print(stones)


for i in range(int(input())):
	(g, b, c) = [int(i) for i in input().split()]
	d = min(c // 2, b)
	print((d + min((b - d) // 2, g)) * 3)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	s = c // 2 * 2
	s1 = s
	if b >= s // 2:
		s1 = s1 + s // 2
		b = b - s // 2
		b = b // 2 * 2
		if a >= b // 2:
			s1 = s1 + b + b // 2
		else:
			s1 = s1 + a * 2 + a
	else:
		s1 = b + b * 2
		b = b // 2
		if a >= b:
			s2 = b + b * 2
			s1 = max(s1, s2)
	print(s1)


def main():
	ans = 0
	(a, b, c) = map(int, input().split())
	(q, w, e) = (a, b, c)
	f1 = 0
	f2 = 0
	while b > 0 and c > 1:
		b -= 1
		c -= 2
		f1 += 3
	while a > 0 and b > 1:
		a -= 1
		b -= 2
		f1 += 3
	while q > 0 and w > 1:
		q -= 1
		w -= 2
		f2 += 3
	while w > 0 and e > 1:
		w -= 1
		e -= 2
		f2 += 3
	ans = max(f1, f2)
	return ans
t = int(input())
for _ in range(t):
	print(main())


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	a2 = a // 2
	b2 = b // 2
	n = 0
	if b >= 1:
		if b > c // 2:
			n += 3 * (c // 2)
			b -= n // 3
		else:
			n += 3 * b
			b = 0
	if a >= 1:
		if a > b // 2:
			n += 3 * (b // 2)
			a -= n // 3
		else:
			n += 3 * a
			a = 0
	print(n)


for t in range(int(input())):
	(a, b, c) = map(int, input().split())
	z = c // 2
	cnt1 = 0
	cnt2 = 0
	if z > b:
		cnt1 += b * 3
		b = 0
	else:
		cnt1 += z * 3
		b -= z
	y = b // 2
	if y > a:
		cnt1 += a * 3
	else:
		cnt1 += y * 3
	print(cnt1)


from sys import stdin
import math
for _ in range(int(stdin.readline())):
	(a, b, c) = list(map(int, stdin.readline().rstrip().split()))
	s = 0
	o2 = min(b, c // 2)
	s += o2 * 3
	o1 = min(a, (b - o2) // 2)
	s += o1 * 3
	print(s)


j = int(input())
ma = []
for i in range(j):
	t = 1
	s = 0
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	while t:
		l = 0
		if b < c and c >= 2 and (b >= 1):
			s = s + 3
			c = c - 2
			b = b - 1
			l = l + 3
		elif b > c and b >= 2 and (a >= 1):
			s = s + 3
			b = b - 2
			a = a - 1
			l = l + 3
		elif a == 0:
			if c >= 2 and b >= 1:
				s = s + 3
				c = c - 2
				b = b - 1
				l = l + 3
		elif a != 0:
			if c >= 2 and b >= 1:
				s = s + 3
				c = c - 2
				b = b - 1
				l = l + 3
			elif b >= 2 and a >= 1:
				s = s + 3
				c = c - 2
				b = b - 1
				l = l + 3
		if l == 0:
			t = 0
	ma.append(s)
for x in ma:
	print(x)


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


def f():
	(a, b, c) = map(int, input().split(' '))
	maxi = 0
	for x in range(0, a + 1):
		for y in range(0, c // 2 + 1):
			if b - 2 * x - y >= 0:
				maxi = max(maxi, 3 * x + 3 * y)
	print(maxi)
for i in range(int(input())):
	f()


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)
threading.stack_size(2 ** 27)
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):
	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):
	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):
	global 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):
	global 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 map(int, stdin.readline().split())

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

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

def cached_fn(fn, *args):
	global 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:
			x += b
		b = b // 2
	return x
TestCases = True
optimise_for_recursion = True

def main():
	(x, y, z) = get_tuple()
	res = min(y, z // 2)
	y -= res
	res += min(x, y // 2)
	print(res * 3)
if TestCases:
	for i in range(get_int()):
		main()
else:
	main() if not optimise_for_recursion else threading.Thread(target=main).start()


def stones(A):
	stones = 0
	while A[0] > 0 and A[1] > 1 or (A[2] > 1 and A[1] > 0):
		if A[2] > 1 and A[1] > 0:
			A[1] -= 1
			A[2] -= 2
			stones += 3
		elif A[0] > 0 and A[1] > 1:
			A[1] -= 2
			A[0] -= 1
			stones += 3
	return stones
t = int(input())
for i in range(t):
	arr = list(map(int, input().split()))
	print(stones(arr))


T = int(input())
s = []
for i in range(T):
	(a, b, c) = map(int, input().split())
	stone = 0
	while c != 0:
		if c // 2 <= b:
			stone = 2 * (c // 2) + c // 2
			b -= c // 2
			break
		else:
			c -= 1
	while b != 0:
		if b // 2 <= a:
			stone = stone + 2 * (b // 2) + b // 2
			a -= b // 2
			break
		else:
			b -= 1
	s.append(stone)
for i in s:
	print(i)


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


n = int(input())
mas = []
for i in range(0, n, 1):
	mas.append(list(map(int, input().split(' '))))
for i in range(0, n, 1):
	counter = 0
	while mas[i][2] >= 2 and mas[i][1] >= 1:
		mas[i][2] -= 2
		mas[i][1] -= 1
		counter += 3
	while mas[i][1] >= 2 and mas[i][0] >= 1:
		mas[i][1] -= 2
		mas[i][0] -= 1
		counter += 3
	print(counter)


t = int(input())
while t > 0:
	abc = list(map(int, input().split()))
	(a, b, c) = (abc[0], abc[1], abc[2])
	ans = 3 * (min(b, int(c / 2)) + min(a, int((b - min(b, int(c / 2))) / 2)))
	print(int(ans))
	t -= 1


q = int(input())
for z in range(0, q):
	l = 0
	a = list(map(int, input().split()))
	c = a[2] // 2
	if a[1] >= c:
		a[1] = a[1] - c
		l = l + c * 3
	else:
		l = l + a[1] * 3
		a[1] = 0
	c = a[1] // 2
	if a[0] >= c:
		l = l + c * 3
	else:
		l = l + a[0] * 3
	print(l)


for _ in range(int(input())):
	(a, b, c) = [int(i) for i in input().split()]
	temp = c // 2
	for i in range(temp, -1, -1):
		if b >= i:
			break
	count = i + 2 * i
	b -= i
	temp = b // 2
	for i in range(temp, -1, -1):
		if a >= i:
			break
	count += i + 2 * i
	print(count)


def fun(a, b):
	if b >= a * 2:
		ar[1] = 0
		stone = a * 3
		return stone
	elif b < a * 2:
		ar[1] -= b // 2
		stone = 3 * (b // 2)
		return stone
for i in range(int(input())):
	ar = list(map(int, input().split()))
	result = 0
	result = fun(ar[1], ar[2]) + fun(ar[0], ar[1])
	print(result)


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


cache = {}

def dp(a, b, c):
	if (a, b, c) in cache:
		return cache[a, b, c]
	if (a == 0 or b <= 1) and (b == 0 or c <= 1):
		result = 0
	elif a == 0 or b <= 1:
		result = 3 + dp(a, b - 1, c - 2)
	elif b == 0 or c <= 1:
		result = 3 + dp(a - 1, b - 2, c)
	else:
		x1 = 3 + dp(a - 1, b - 2, c)
		x2 = 3 + dp(a, b - 1, c - 2)
		result = max(x1, x2)
	cache[a, b, c] = result
	return result
t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	print(dp(a, b, c))


t = int(input())
abc = []
for x in range(1, t + 1):
	abc += input().split(' ')
for test_num in range(0, t):
	abc[0 + test_num * 3] = int(abc[0 + test_num * 3])
	abc[1 + test_num * 3] = int(abc[1 + test_num * 3])
	abc[2 + test_num * 3] = int(abc[2 + test_num * 3])
	result = 0
	while True:
		if abc[2 + test_num * 3] >= 2 and abc[1 + test_num * 3] >= 1:
			result += 3
			abc[2 + test_num * 3] -= 2
			abc[1 + test_num * 3] -= 1
		else:
			break
	while True:
		if abc[1 + test_num * 3] >= 2 and abc[0 + test_num * 3] >= 1:
			result += 3
			abc[1 + test_num * 3] -= 2
			abc[0 + test_num * 3] -= 1
		else:
			break
	print(result)


t = int(input())
while t != 0:
	L = list(map(int, input().split()))
	sum = 0
	k = min(int(L[2] / 2), L[1])
	sum = sum + 3 * k
	L[1] = L[1] - k
	k = min(int(L[1] / 2), L[0])
	sum = sum + 3 * k
	print(sum)
	t = t - 1


p = []
s = 0
for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	if b == 0:
		p.append(0)
	else:
		while c > 1 and b > 0:
			b -= 1
			c -= 2
			s += 3
		while b > 1 and a > 0:
			a -= 1
			b -= 2
			s += 3
		p.append(s)
	s = 0
for i in range(len(p)):
	print(p[i])


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7
for i in range(INT()):
	(a, b, c) = MAP()
	cnt = 0
	while b > 0 and c > 1:
		cnt += 3
		b -= 1
		c -= 2
	while a > 0 and b > 1:
		cnt += 3
		a -= 1
		b -= 2
	print(cnt)


t = int(input())
for i in range(t):
	(a, b, c) = list(map(int, input().split()))
	if b == 0:
		print(0)
	elif c >= b and b > 0 and (c > 1) or (b > c and c > 1):
		if b >= c // 2:
			count = 2 * (c // 2) + c // 2
			b -= c // 2
			c -= 2 * (c // 2)
		else:
			count = b + 2 * b
			c -= 2 * b
			b -= b
		if a > 0 and b > 1:
			if a >= b // 2:
				count += 2 * (b // 2) + b // 2
			else:
				count += a + 2 * a
		print(count)
	elif b > c and a > 0 and (b > 1):
		if a >= b // 2:
			count = 2 * (b // 2) + b // 2
			a -= b // 2
			b -= 2 * (b // 2)
		else:
			count = a + 2 * a
			b -= 2 * a
			a -= a
		if b > 0 and c > 1:
			if b >= c // 2:
				count += 2 * (c // 2) + c // 2
			else:
				count += b + 2 * b
		print(count)
	else:
		print(0)


n = int(input())
for i in range(n):
	(x, y, z) = map(int, input().split())
	if y < z // 2:
		print(3 * y)
	else:
		y = y - z // 2
		if x > y // 2:
			print(3 * (z // 2 + y // 2))
		else:
			print(3 * (z // 2 + x))


from sys import stdout, stdin
for i in range(int(stdin.readline())):
	(a, b, c) = stdin.readline().split()
	(a, b, c) = (int(a), int(b), int(c))
	cont = 0
	cant_c = c // 2
	cant_b_con_c = b
	if cant_c <= cant_b_con_c:
		cont += cant_c * 2
		cont += cant_c
		b = b - cant_c
	else:
		cont += cant_b_con_c * 2
		cont += cant_b_con_c
		b = b - cant_b_con_c
	cant_a = a
	cant_b_con_a = b // 2
	if cant_b_con_a <= cant_a:
		cont += cant_b_con_a * 2
		cont += cant_b_con_a
	else:
		cont += cant_a * 2
		cont += cant_a
	stdout.write(str(cont) + '\n')


def stone(a, b, c):
	count = 0
	p = max(a, b, c)
	for i in range(p):
		if c >= 2 and b >= 1:
			count += 3
			if c < 2 or b < 1:
				return
			c = c - 2
			b = b - 1
		elif b >= 2 and a >= 1:
			count += 3
			if b < 2 or a < 1:
				return
			b = b - 2
			a = a - 1
	return count
t = int(input())
for i in range(t):
	(a, b, c) = [int(i) for i in input().split()]
	ans = stone(a, b, c)
	print(ans)


q = int(input())
Ans = []
for i in range(q):
	(a, b, c) = map(int, input().split())
	operbc = min(b, c // 2)
	b -= operbc
	operab = min(a, b // 2)
	Ans.append((operbc + operab) * 3)
for i in range(q):
	print(Ans[i])


t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = input().split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	x = min(a, b // 2)
	y = min(b, c // 2)
	res1 = x * 3 + min(b - 2 * x, c // 2) * 3
	res2 = y * 3 + min((b - y) // 2, a) * 3
	print(max(res1, res2))


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


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	s = 0
	if c // 2 >= b:
		s += 3 * b
	else:
		x = c // 2
		s += 3 * x
		b = b - x
		y = b // 2
		if b // 2 >= a:
			s += 3 * a
		else:
			s += 3 * y
	print(s)
	t -= 1


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


t = int(input())
for case in range(t):
	(a, b, c) = [int(s) for s in input().split(' ')]
	x = 3 * min(c // 2, b)
	b -= x // 3
	x += 3 * min(a, b // 2)
	print(x)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	(m, n, o) = (a, b, c)
	s = 0
	if n <= o // 2:
		s += 3 * n
		o -= n * 2
		n = 0
	else:
		s += 3 * (o // 2)
		n -= o // 2
		o -= 2 * (o // 2)
	if m <= n // 2:
		s += 3 * m
		n -= m * 2
		m = 0
	else:
		s += 3 * (n // 2)
		m -= n // 2
		n -= 2 * (n // 2)
	j = s
	s = 0
	(m, n, o) = (a, b, c)
	if m <= n // 2:
		s += 3 * m
		n -= m * 2
		m = 0
	else:
		s += 3 * (n // 2)
		m -= n // 2
		n -= 2 * (n // 2)
	if n <= o // 2:
		s += 3 * n
		o -= n * 2
		n = 0
	else:
		s += 3 * (o // 2)
		n -= o // 2
		o -= 2 * (o // 2)
	print(j if j >= s else s)


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)


def max_stones(b, c):
	count = 0
	if b < c:
		t = c // 2
		if t < b:
			count += t
			b -= t
		else:
			return [b * 3]
	else:
		count += c // 2
		b -= count
	return [count * 3, b]

def solution(a, b, c):
	first = max_stones(b, c)
	stones = first[0]
	if len(first) == 2:
		stones += max_stones(a, first[1])[0]
	return stones
for z in range(int(input())):
	x = [int(i) for i in input().split()]
	print(solution(x[0], x[1], x[2]))


t = int(input())

def solve(a, b, c):
	max_stones = 0
	while c > 1 and b > 0:
		c -= 2
		b -= 1
		max_stones += 3
	while b > 1 and a > 0:
		b -= 2
		a -= 1
		max_stones += 3
	return max_stones
for i in range(t):
	stones = list((int(i) for i in input().split()))
	a = stones[0]
	b = stones[1]
	c = stones[2]
	print(solve(a, b, c))


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


import sys, math
input = sys.stdin.readline
n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	q = 0
	ww = 0
	if b > 0:
		bb = b
		if c > 1:
			q = min(c // 2, b) * 3
			bb = b - q // 3
		if bb > 1 and a > 0:
			w = min(bb // 2, a) * 3
			q = q + w
		if b > 1 and a > 0:
			ww = min(b // 2, a) * 3
			bb = b - 2 * (ww // 3)
		if bb > 0 and c > 1:
			w = min(c // 2, bb) * 3
			ww = ww + w
	print(max(q, ww))


def _solve(a: int, b: int, c: int) -> int:
	left = min(a, b // 2)
	a -= left
	b -= left * 2
	while left >= 0:
		right = min(b, c // 2)
		yield (3 * (left + right))
		left -= 1
		a += 1
		b += 2

def solve(a: int, b: int, c: int) -> int:
	return max(_solve(a, b, c), default=0)

def main():
	for _ in range(int(input())):
		(a, b, c) = map(int, input().split())
		print(solve(a, b, c))
main()


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


def conta_pedras(ent):
	if ent[1] == 0:
		return 0
	else:
		cont = 0
		if ent[2] == 0 or ent[2] == 1:
			if ent[1] // 2 > ent[0]:
				return 3 * ent[0]
			else:
				return 3 * (ent[1] // 2)
		else:
			if ent[2] // 2 > ent[1]:
				return 3 * ent[1]
			else:
				cont += 3 * (ent[2] // 2)
				ent[1] -= ent[2] // 2
				ent[2] -= 2 * (ent[2] // 2)
				if ent[1] // 2 > ent[0]:
					cont += 3 * ent[0]
				else:
					cont += 3 * (ent[1] // 2)
			return cont
n = int(input())
for i in range(0, n):
	ent = list(map(int, input().strip().split()))[:3]
	print(conta_pedras(ent))


import sys
from functools import lru_cache

@lru_cache(maxsize=None)
def solve(a, b, c):
	res = 0
	if a >= 1 and b >= 2:
		res = max(res, 3 + solve(a - 1, b - 2, c))
	if b >= 1 and c >= 2:
		res = max(res, 3 + solve(a, b - 1, c - 2))
	return res
sys.setrecursionlimit(9001)
for _ in range(int(input())):
	arr = [int(x) for x in input().split()]
	print(solve(arr[0], arr[1], arr[2]))


n = int(input())
for _ in range(n):
	tot = 0
	x = list(map(int, input().split()))
	while x[2] >= 2 and x[1] >= 1:
		x[2] -= 2
		x[1] -= 1
		tot += 3
	while x[0] >= 1 and x[1] >= 2:
		x[0] -= 1
		x[1] -= 2
		tot += 3
	print(tot)


for case in ' ' * int(input()):
	(a, b, c) = map(int, input().split())
	c = c // 2
	d = b - c
	if d < 0:
		c = c + d
	b = b - c
	b = b // 2
	d = a - b
	if d < 0:
		b = b + d
	print(2 * c + c + 2 * b + b)


t = int(input())
while t != 0:
	t -= 1
	(a, b, c) = [int(x) for x in input().split()]
	f1 = min(c // 2, b)
	c1 = f1 + min((b - f1) // 2, a)
	f1 = min(b // 2, a)
	c2 = f1 + min(c // 2, b - 2 * f1)
	print(max(c1, c2) * 3)


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


queries = int(input())
for x in range(queries):
	count = 0
	stones = input()
	stones = stones.split()
	stones = [int(x) for x in stones]
	for x in range(max(stones)):
		if stones[0] > 0 and stones[1] > 1 or (stones[1] > 0 and stones[2] > 1):
			count += 3
			if stones[1] > 0 and stones[2] > 1:
				stones[1] = stones[1] - 1
				stones[2] = stones[2] - 2
			else:
				stones[0] -= 1
				stones[1] -= 2
		else:
			break
	print(count)


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


for _ in range(int(input())):
	(a, b, c) = input().split()
	(a, b, c) = (int(a), int(b), int(c))
	count = 0
	if b == 0:
		print(0)
	else:
		k1 = c // 2
		count += 3 * min(k1, b)
		b -= count // 3
		if b > 1:
			k2 = b // 2
			count += 3 * min(k2, a)
		print(count)


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


q = int(input())
for i in range(q):
	ans = 0
	(w, e, r) = map(int, input().split())
	while r > 1 and e > 0:
		ans += 3
		r -= 2
		e -= 1
	while e > 1 and w > 0:
		ans += 3
		e -= 2
		w -= 1
	print(ans)


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


for i in range(int(input())):
	r = list(map(int, input().split()))
	p = 0
	while i != -20:
		if r[2] >= 2 and r[1] >= 1:
			r[1] = r[1] - 1
			r[2] = r[2] - 2
			p = p + 3
		elif r[1] >= 2 and r[0] >= 1:
			r[0] = r[0] - 1
			r[1] = r[1] - 2
			p = p + 3
		else:
			break
	print(p)


c = int(input())
heaps = []
mx = []
for i in range(0, c):
	mx.append(-2)
for i in range(0, c):
	heaps.append(input().split(' '))
for i in range(0, c):
	for j in range(0, len(heaps[i])):
		heaps[i][j] = int(heaps[i][j])
for i in range(0, c):
	a = heaps[i][0]
	b = heaps[i][1]
	c = heaps[i][2]
	summ = 0
	while c >= 2 and b >= 1:
		b = b - 1
		c = c - 2
		summ = summ + 3
	while b >= 2 and a >= 1:
		a = a - 1
		b = b - 2
		summ = summ + 3
	mx[i] = summ
	print(summ)


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


for _ in range(int(input())):
	(a, b, c) = [int(i) for i in input().split()]
	res1 = 0
	temp1 = min(a, b // 2)
	res1 += 3 * temp1
	b -= 2 * temp1
	temp2 = min(b, c // 2)
	res1 += 3 * temp2
	b += 2 * temp1
	res2 = 0
	temp1 = min(b, c // 2)
	res2 += 3 * temp1
	b -= temp1
	temp2 = min(a, b // 2)
	res2 += 3 * temp2
	print(max(res1, res2))


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	d = a
	e = b
	f = c
	if b == 0:
		print(0)
	else:
		count = 0
		while a > 0 and b > 1:
			a = a - 1
			b = b - 2
			count = count + 3
		while b > 0 and c > 1:
			b = b - 1
			c = c - 2
			count = count + 3
		count1 = 0
		while e > 0 and f > 1:
			e = e - 1
			f = f - 2
			count1 = count1 + 3
		while d > 0 and e > 1:
			d = d - 1
			e = e - 2
			count1 = count1 + 3
		print(max(count, count1))


import sys

class Test:

	def __init__(self, test_input: str):
		test_input_list = test_input.split()
		self.a = int(test_input_list[0])
		self.b = int(test_input_list[1])
		self.c = int(test_input_list[2])

	@property
	def can_do_first(self) -> bool:
		if self.a > 0 and self.b > 1:
			return True
		else:
			return False

	@property
	def can_do_second(self) -> bool:
		if self.b > 0 and self.c > 1:
			return True
		else:
			return False

	def do_first(self):
		self.a = self.a - 1
		self.b = self.b - 2

	def do_second(self):
		self.b = self.b - 1
		self.c = self.c - 2

def test_solution(test_input: str):
	test = Test(test_input)
	answer = 0
	while test.can_do_second:
		test.do_second()
		answer += 3
	while test.can_do_first:
		test.do_first()
		answer += 3
	return answer
n = int(sys.stdin.readline())
answers = []
for i in range(n):
	test_input = sys.stdin.readline()
	answer = test_solution(test_input)
	answers.append(answer)
for answer in answers:
	sys.stdout.write(str(answer) + '\n')


n = int(input())
for i in range(n):
	list_of_piles = list(map(int, input().split()))
	pile1 = list_of_piles[0]
	pile2 = list_of_piles[1]
	pile3 = list_of_piles[2]
	counter = 0
	while pile2 > 0 and pile3 > 1:
		counter += 3
		pile2 -= 1
		pile3 -= 2
	while pile1 > 0 and pile2 > 1:
		counter += 3
		pile1 -= 1
		pile2 -= 2
	print(counter)


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


import math
for _ in range(int(input())):
	abc = list(str(input()).split(' '))
	a = int(abc[0])
	b = int(abc[1])
	c = int(abc[2])
	stone = 0
	if c >= 2 and b >= 1:
		if b >= math.floor(c / 2):
			stone += math.floor(c / 2) * 3
			b -= math.floor(c / 2)
		else:
			stone += 3 * b
			b = 0
	if b >= 2 and a >= 1:
		if a >= math.floor(b / 2):
			stone += math.floor(b / 2) * 3
		else:
			stone += 3 * a
	print(stone)


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


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


t = int(input())
for _ in range(t):
	a = list(map(int, input().split()))
	ans = 0
	l = a[2] // 2
	l = min(l, a[1])
	ans += 3 * l
	a[1] -= l
	l = a[1] // 2
	l = min(l, a[0])
	ans += 3 * l
	print(ans)


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	ans = 0
	for i in range(0, 100):
		for j in range(0, 100):
			if i <= a and 2 * i + j <= b and (2 * j <= c):
				ans = max(ans, 3 * (i + j))
	print(ans)


t = int(input())
for _ in range(t):
	(a, b, c) = [int(x) for x in str(input()).split()]
	stones = 0
	stones = min(b, c // 2)
	b = b - stones
	stones = 3 * stones
	stones = stones + 3 * min(a, b // 2)
	print(stones)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	(a, b, c) = map(int, input().split())
	ans = 0
	moves = min(b, c // 2)
	b -= moves
	c -= 2 * moves
	ans += 3 * moves
	move2 = min(a, b // 2)
	ans += 3 * move2
	print(ans)


n = int(input())

def isPossible(a, b):
	if a > 0 and b > 1:
		return True
	return False
result = []
for x in range(n):
	(a, b, c) = [int(x) for x in input().split()]
	maxx = max(a, b, c)
	count = 0
	while a >= 1 and b >= 2 or (b >= 1 and c >= 2):
		maxx = max(a, b, c)
		if maxx == b:
			if isPossible(b, c):
				b -= 1
				c -= 2
				count += 3
			elif isPossible(a, b):
				a -= 1
				b -= 2
				count += 3
		elif maxx == c:
			if isPossible(b, c):
				b -= 1
				c -= 2
				count += 3
			elif isPossible(a, b):
				a -= 1
				b -= 2
				count += 3
		elif isPossible(b, c):
			b -= 1
			c -= 2
			count += 3
		elif isPossible(a, b):
			a -= 1
			b -= 2
			count += 3
	result.append(count)
for x in result:
	print(x)


t = int(input())
salida = [0] * t
for i in range(0, t):
	cad = input()
	cad = cad.split(' ')
	a = int(cad[0])
	b = int(cad[1])
	c = int(cad[2])
	x = 0
	while a >= 1 and b >= 2 or (b >= 1 and c >= 2):
		if b > c:
			if a >= 1 and b >= 2:
				x = x + 3
				a = a - 1
				b = b - 2
			else:
				x = x + 3
				b = b - 1
				c = c - 2
		elif b >= 1 and c >= 2:
			x = x + 3
			b = b - 1
			c = c - 2
		else:
			x = x + 3
			a = a - 1
			b = b - 2
	salida[i] = x
for i in range(0, t):
	print(salida[i])


testCases = int(input())
ret = []
for c in range(testCases):
	ret.append(0)
	(first, second, third) = map(int, input().split(' '))
	(firstCheck, secondCheck) = (True, True)
	while secondCheck:
		if second > 0 and third > 1:
			ret[c] += 3
			second = second - 1
			third = third - 2
		else:
			secondCheck = False
	while firstCheck:
		if first > 0 and second > 1:
			ret[c] += 3
			first = first - 1
			second = second - 2
		else:
			firstCheck = False
for result in ret:
	print(result)


def stones(stonepile):
	count = 0
	while stonepile[0] >= 1 and stonepile[1] >= 2 or (stonepile[1] >= 1 and stonepile[2] >= 2):
		if stonepile[1] > stonepile[2] // 2 and (stonepile[0] >= 1 and stonepile[1] >= 2):
			stonepile[0] -= 1
			stonepile[1] -= 2
			count += 3
		else:
			stonepile[1] -= 1
			stonepile[2] -= 2
			count += 3
	return count
t = int(input())
for i in range(t):
	arr = list(map(int, input().split()))
	print(stones(arr))


t = int(input())
kq = []
for i in range(t):
	stone = [int(c) for c in input().split()]
	if stone[1] == 0:
		kq.append(0)
	else:
		c = int(stone[2] / 2)
		b = stone[1] - c
		if b < 0:
			kq.append(3 * stone[1])
		elif b == 0:
			kq.append(3 * c)
		else:
			a = stone[0] - int(b / 2)
			if a >= 0:
				kq.append(3 * c + 3 * int(b / 2))
			else:
				kq.append(3 * c + 3 * stone[0])
for i in range(t):
	print(kq[i])


t = int(input())
for i in range(t):
	(a, b, c) = [int(item) for item in input().split()]
	result = 0
	if b == 0:
		result = 0
	else:
		totalC = c // 2
		if b <= totalC:
			result += b
			result += b * 2
			b = 0
		elif c >= 2:
			result += totalC
			result += totalC * 2
			b -= totalC
			c -= 2 * totalC
		if b >= 2:
			totalB = b // 2
			if totalB > 0:
				if b >= 2 and a > 0:
					if a >= totalB:
						result += totalB
						result += totalB * 2
					else:
						result += a
						result += a * 2
	print(result)


import os, sys, math
import collections
if os.path.exists('testing'):
	name = os.path.basename(__file__)
	if name.endswith('.py'):
		name = name[:-3]
	src = open(name + '.in.txt', encoding='utf8')
	input = src.readline

def solve(a, b, c):
	bc_count = min(b, c // 2)
	b -= bc_count
	ab_count = min(a, b // 2)
	return (ab_count + bc_count) * 3
n = int(input().strip())
for _ in range(n):
	(a, b, c) = map(int, input().strip().split())
	r = solve(a, b, c)
	print(r)


n = int(input())
for i in range(n):
	sum = 0
	x = list(map(int, input().split()))
	while x[0] > 0 or x[1] > 0:
		if x[2] >= 2 and x[1] >= 1:
			sum += 3
			x[1] -= 1
			x[2] -= 2
		elif x[1] > 1 and x[0] > 0:
			sum += 3
			x[0] -= 1
			x[1] -= 2
		else:
			break
	print(sum)


t = int(input())
while t:
	t -= 1
	(a, b, c) = [int(x) for x in input().split()]
	a1 = min(a, b // 2)
	k = b - a1 * 2
	a2 = min(k, c // 2)
	a3 = min(b, c // 2)
	b -= a3
	a4 = min(a, b // 2)
	j1 = 3 * (a1 + a2)
	j2 = 3 * (a3 + a4)
	print(max(j1, j2))


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	s1 = 0
	s2 = 0
	m = 0
	while b >= 1 and c >= 2:
		s1 += 3
		b -= 1
		c -= 2
	if s1 > 0 and a >= 1 and (b >= 2):
		while a >= 1 and b >= 2:
			s1 += 3
			a -= 1
			b -= 2
	while a >= 1 and b >= 2:
		s2 += 3
		b -= 2
		a -= 1
	if s2 > 0 and b >= 1 and (c >= 2):
		while b >= 1 and c >= 2:
			s2 += 3
			b -= 1
			c -= 2
	m = max(s1, s2)
	if m > 0:
		print(m)
	else:
		print('0')


import math
n = int(input())
ans = list(range(n))
for i in range(n):
	a = [int(x) for x in input().split(' ')]
	q = math.floor(a[2] / 2)
	ans[i] = 0
	if q >= a[1]:
		ans[i] = ans[i] + a[1] * 3
	elif q < a[1]:
		ans[i] = ans[i] + q * 3
		a[1] = a[1] - q
		q1 = math.floor(a[1] / 2)
		if q1 >= a[0]:
			ans[i] = ans[i] + a[0] * 3
		else:
			ans[i] = ans[i] + q1 * 3
for i in range(n):
	print(ans[i])


def func(a, b, c):
	count = 0
	while c >= 2 and b >= 1:
		c -= 2
		b -= 1
		count += 3
	while a >= 1 and b >= 2:
		a -= 1
		b -= 2
		count += 3
	return count
t = int(input())
stones = []
for i in range(t):
	s = list(input().split(' '))
	stones.append(func(int(s[0]), int(s[1]), int(s[2])))
for i in stones:
	print(i)


t = int(input())
while t > 0:
	(x, y, z) = [int(i) for i in input().split()]
	s = 0
	f = -1
	z = z // 2
	if y >= z:
		y = y - z
		s = z * 2 + z
	else:
		s = y * 2 + y
		f = 1
	if f == -1:
		y = y // 2
		if x >= y:
			s = s + 2 * y + y
		else:
			s = s + 2 * x + x
	print(s)
	t -= 1


t = int(input())
for _ in range(t):
	ans = 0
	(ai, bi, ci) = map(int, input().split())
	for x in range(101):
		for y in range(101):
			if ai >= x and bi >= 2 * x + y and (ci >= 2 * y):
				ans = max(ans, 3 * x + 3 * y)
	print(ans)


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	if x >= 1 and y >= 2 or (y >= 1 and z >= 2):
		z = int(z / 2)
		temp = y - z
		if temp >= 2:
			y = int(temp / 2)
			k = x - y
			if k >= 0:
				ans = 3 * z + 3 * y
				print(ans)
			else:
				ans = 3 * z + 3 * x
				print(ans)
		elif temp >= 0:
			print(3 * z, end='\n')
		else:
			print(3 * y, end='\n')
	else:
		print('0', end='\n')


t = int(input())
for t in range(t):
	result = 0
	(a, b, c) = map(int, input().split())
	if b == 0:
		result = 0
	else:
		if c >= 2 and b >= 1:
			temp = int(c / 2)
			if temp > b:
				temp = b
				while temp * 2 > c:
					temp -= 1
				b -= temp
				result += temp * 2 + temp
			else:
				result += temp * 2 + temp
				b -= temp
		if b >= 2 and a >= 1:
			temp = int(b / 2)
			if temp > a:
				temp = a
				while temp * 2 > b:
					temp -= 1
				a -= temp
				result += temp * 2 + temp
			else:
				result += temp * 2 + temp
	print(result)


n = int(input())

def cal(x, y, z):
	cnt = 0
	while x > 0 and y > 1:
		x -= 1
		y -= 2
		cnt += 3
	while y > 0 and z > 1:
		y -= 1
		z -= 2
		cnt += 3
	return cnt

def calc(x, y, z):
	num = 0
	while y > 0 and z > 1:
		y -= 1
		z -= 2
		num += 3
	while x > 0 and y > 1:
		x -= 1
		y -= 2
		num += 3
	return num
for i in range(n):
	(a, b, c) = map(int, input().split())
	(e, f, g) = (a, b, c)
	t = cal(a, b, c)
	m = calc(e, f, g)
	print(max(t, m))


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	profit = 0
	if b == 0 or a == b == c == 0:
		print(0)
	else:
		while True:
			if b == 0 or c == 0 or c == 1:
				break
			profit = 3 + profit
			b = b - 1
			c = c - 2
		while True:
			if b == 0 or a == 0 or b == 1:
				break
			profit = profit + 3
			a = a - 1
			b = b - 2
		print(profit)


n = int(input())
l = []
for i in range(n):
	count = 0
	k = list(map(int, input().split()))
	if k[1] == 1 and k[2] == 1:
		l.append(0)
	else:
		while k[2] > 1 and k[1] >= 1:
			count = count + 3
			k[2] = k[2] - 2
			k[1] = k[1] - 1
		while k[1] > 1 and k[0] >= 1:
			count = count + 3
			k[1] = k[1] - 2
			k[0] = k[0] - 1
		l.append(count)
for i in l:
	print(i)


exec(int(input()) * 'a,b,c=map(int,input().split());d=min(c//2,b);print(min(a,(b-d)//2)*3+d*3);')


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


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


StoneHeaps = []
R = []
S = 0
for i in range(int(input())):
	(S1, S2, S3) = [int(_) for _ in input().split()]
	if S2 == 0:
		R.append(0)
		continue
	if S3 >= 2 and S2 >= 1:
		while True:
			if S3 < 2 or S2 < 1:
				break
			S3 -= 2
			S2 -= 1
			S += 3
	if S2 >= 2 and S1 >= 1:
		while True:
			if S2 < 2 or S1 < 1:
				break
			S2 -= 2
			S1 -= 1
			S += 3
	R.append(S)
	S = 0
for j in R:
	print(j)


n = int(input())
for i in range(n):
	L = [int(j) for j in input().split()]
	stones = 0
	while L[2] >= 2 and L[1] >= 1:
		L[1] -= 1
		L[2] -= 2
		stones += 3
	while L[0] >= 1 and L[1] >= 2:
		L[0] -= 1
		L[1] -= 2
		stones += 3
	print(stones)


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


testCases = int(input())
for t in range(testCases):
	(a, b, c) = tuple(map(int, input().split(' ')))
	num_op_y = min(b, c // 2)
	num_op_x = min(a, (b - num_op_y) // 2)
	print(3 * (num_op_x + num_op_y))


t = int(input())
while t > 0:
	(a, b, c) = input().split()
	b = int(b)
	a = int(a)
	c = int(c)
	count = 0
	count1 = 0
	answer = 0
	if b == 0:
		print(0)
	else:
		while b > 0 and c > 1:
			c = c - 2
			count = count + 1
			b = b - 1
		answer = answer + count * 2 + count
		while b > 1 and a > 0:
			b = b - 2
			count1 = count1 + 1
			a = a - 1
		answer = answer + count1 * 2 + count1
		print(answer)
	t = t - 1


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


t = int(input())
for _ in range(t):
	(n1, n2, n3) = map(int, input().split())
	co = 0
	while n3 >= 2 and n2 >= 1:
		co += 3
		n3 -= 2
		n2 -= 1
	while n2 >= 2 and n1 >= 1:
		co += 3
		n2 -= 2
		n1 -= 1
	print(co)


T = int(input())
for _ in range(T):
	(a, b, c) = (int(x) for x in input().split())
	result = 0
	while c >= 2 and b >= 1:
		result += 3
		c -= 2
		b -= 1
	while b >= 2 and a >= 1:
		result += 3
		b -= 2
		a -= 1
	print(result)


try:
	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 a >= 1 and b >= 2:
			ans += 3
			a -= 1
			b -= 2
		print(ans)
except EOFError:
	pass


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	count = 0
	if c >= 2:
		if c // 2 > b:
			count += 3 * b
			b = 0
		else:
			count += 3 * (c // 2)
			b -= c // 2
	if b >= 2:
		if b // 2 > a:
			count += 3 * a
			a = 0
		else:
			count += 3 * (b // 2)
			a -= b // 2
	print(count)
	t -= 1


def brute_force_left(a, b):
	best = min(a, b // 2)
	cost = 2 * best + best
	if a < b // 2:
		return (cost, b - best * 2)
	return (cost, 0)

def brute_force_right(b, c):
	best = min(b, c // 2)
	cost = 2 * best + best
	if b < c // 2:
		return (cost, 0)
	return (cost, b - c // 2)
for i in range(int(input())):
	(a, b, c) = map(int, input().split(' '))
	(cost_0, residue) = brute_force_left(a, b)
	(cost_1, _) = brute_force_left(residue, c)
	total_left = cost_0 + cost_1
	(cost_0, residue) = brute_force_right(b, c)
	(cost_1, _) = brute_force_right(a, residue)
	total_right = cost_0 + cost_1
	print(max(total_left, total_right))


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	if b > c // 2:
		w = b - c // 2
		z = min(a, w // 2) + c // 2
		print(z * 3)
	else:
		print(b * 3)


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


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


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


t = int(input())
s = []
for jnnj in range(0, t):
	x = input()
	xx = x.split()
	a = int(xx[0])
	b = int(xx[1])
	c = int(xx[2])
	g = 0
	if b == 0:
		s.append(0)
	else:
		while b >= 1 and c >= 2:
			g += 3
			b -= 1
			c -= 2
		while b >= 2 and a >= 1:
			g += 3
			a -= 1
			b -= 2
		s.append(g)
for i in s:
	print(i)


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


for i in range(int(input())):
	k = list(map(int, input().split()))
	ans = 0
	while k[0] > 0 and k[1] > 1 or (k[1] > 0 and k[2] > 1):
		ans += 3
		if min(k[0], k[1] // 2) > min(k[1], k[2] // 2):
			k[0] -= 1
			k[1] -= 2
		else:
			k[2] -= 2
			k[1] -= 1
	print(ans)


def cout_stone(stone):
	stone[0] = int(stone[0])
	stone[1] = int(stone[1])
	stone[2] = int(stone[2])
	sum = 0
	if stone[1] >= stone[2] // 2:
		sum = stone[2] // 2 * 3
		stone[1] -= stone[2] // 2
		if stone[0] >= stone[1] // 2:
			sum += stone[1] // 2 * 3
		else:
			sum += stone[0] * 3
	else:
		sum += stone[1] * 3
	print(sum)
n = int(input())
i = 0
stone = []
while i < n:
	s = input().split(' ')
	stone.append(s)
	i += 1
for i in range(n):
	cout_stone(stone[i])


t = int(input())
for i in range(t):
	(s1, s2, s3) = map(int, input().split())
	s = 0
	for k1 in range(s1 + 1):
		if s2 - 2 * k1 >= 0:
			k2 = min(s2 - 2 * k1, s3 // 2)
			if s < 3 * (k1 + k2):
				s = 3 * (k1 + k2)
	if s1 == 0:
		k2 = min(s2, s3 // 2)
		s = 3 * k2
	print(s)


t = int(input())
for i in range(t):
	alist = list(map(int, input().split()))
	flag = 0
	ans = 0
	while alist[2] > 1 and alist[1] > 0:
		ans += 3
		alist[2] -= 2
		alist[1] -= 1
	while alist[1] > 1 and alist[0] > 0:
		ans += 3
		alist[1] -= 2
		alist[0] -= 1
	print(ans)


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


q = int(input())
for t in range(q):
	(a, b, c) = [int(i) for i in input().split(' ')]
	stones = 0
	if b >= c // 2:
		b = b - c // 2
		stones += c // 2 * 2 + c // 2
	else:
		stones += b + 2 * b
		b = 0
	if b > 1:
		if a >= b // 2:
			stones += b // 2 * 2 + b // 2
		else:
			stones += a + 2 * a
	print(stones)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	d = b // 1
	e = c // 2
	ans = 0
	if d >= 1 and e >= 1:
		p = min(d, e)
		b = b - p
		ans += 3 * p
	d = a // 1
	e = b // 2
	if d >= 1 and e >= 1:
		p = min(d, e)
		ans += 3 * p
	print(ans)


t = int(input())
o = [0] * t
p = [0] * t
r = [0] * t
for i in range(t):
	(o[i], p[i], r[i]) = [int(x) for x in input().split()]
for i in range(t):
	a = o[i]
	b = p[i]
	c = r[i]
	Max = 0
	for x in range(min(101, a + 1)):
		for y in range(min(101, int(c / 2) + 1)):
			if 2 * x + y <= b and x + y > Max:
				Max = x + y
	print(3 * Max)


def stones(a, b, c):
	r = 0
	while c >= 2:
		if b >= 1:
			c -= 2
			b -= 1
			r += 3
		else:
			break
	while b >= 2:
		if a >= 1:
			a -= 1
			b -= 2
			r += 3
		else:
			break
	return r

def main():
	for i in range(int(input())):
		(a, b, c) = map(int, input().split(' '))
		print(stones(a, b, c))
main()


import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(4100000)
INF = 1 << 60
MOD = 10 ** 9 + 7
t = int(input())
for i in range(t):
	(a1, b1, c1) = map(int, input().split())
	(a2, b2, c2) = (a1, b1, c1)
	cnt1 = min(a1, b1 // 2)
	ans1 = cnt1 * 3
	b1 -= cnt1 * 2
	cnt2 = min(b1, c1 // 2)
	ans1 += cnt2 * 3
	cnt3 = min(b2, c2 // 2)
	ans2 = cnt3 * 3
	b2 -= cnt3
	cnt4 = min(a2, b2 // 2)
	ans2 += cnt4 * 3
	print(max(ans1, ans2))


t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	res = 0
	if a == 0:
		temp = c // 2
		if b >= temp:
			res = 3 * temp
		else:
			res = 3 * b
		print(res)
		continue
	elif b == 0:
		res = 0
		print(res)
		continue
	elif c == 0:
		temp = b // 2
		if a >= temp:
			res = 3 * temp
		else:
			res = 3 * a
		print(res)
		continue
	else:
		while c >= 2:
			if b == 0:
				break
			else:
				res += 3
				b -= 1
				c -= 2
		while b >= 2:
			if a == 0:
				break
			else:
				res += 3
				b -= 2
				a -= 1
		print(res)


t = int(input())
while t > 0:
	t -= 1
	(a, b, c) = input().split()
	a = int(a)
	b = int(b)
	c = int(c)
	sum = 0
	r = 0
	e = 0
	while b >= 2 and a >= 1 or (c >= 2 and b >= 1):
		e = 0
		r = 0
		if c >= 2 and b >= 1:
			c -= 2
			b -= 1
			e = 1
			sum = sum + 3
		elif b >= 2 and a >= 1:
			b -= 2
			a -= 1
			r = 1
			sum = sum + 3
		if e == 0 and r == 0:
			break
	print(sum)


test_cases = int(input())
for each_test_case in range(test_cases):
	(a, b, c) = map(int, input().split())
	times_c = c // 2
	scd_operation = min(b, times_c)
	b -= scd_operation
	times_b = b // 2
	first_operation = min(a, times_b)
	print((first_operation + scd_operation) * 3)


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	sum = a + b + c
	if c:
		s = c // 2
		if b >= s:
			c = c - s * 2
			b = b - s
		else:
			c = c - b * 2
			b = 0
	if b:
		s = b // 2
		if a >= s:
			b = b - s * 2
			a = a - s
		else:
			b = b - a * 2
			a = 0
	print(sum - (a + b + c))


def solution(t):
	total_arr = []
	for i in range(t):
		total = 0
		(a, b, c) = map(int, input().split())
		t = min(b, c // 2)
		b = b - t
		total = total + t + t * 2
		t = min(a, b // 2)
		total += t + t * 2
		total_arr.append(total)
	print('\n'.join(map(str, total_arr)))

def main():
	t = int(input())
	solution(t)
main()


def recur(a, b, c, maxi):
	if a >= 1 and b >= 2 and (c >= 2):
		return recur(a, b - 1, c - 2, maxi + 3)
	if a >= 1 and b >= 2:
		return recur(a - 1, b - 2, c, maxi + 3)
	if b >= 1 and c >= 2:
		return recur(a, b - 1, c - 2, maxi + 3)
	return maxi
n = int(input())
for i in range(n):
	l = list(map(int, input().split(' ')))
	maxi = recur(l[0], l[1], l[2], 0)
	print(maxi)


import sys, math, queue, collections
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	ans = 3 * min(b, c // 2)
	b = b - min(b, c // 2)
	ans += 3 * min(a, b // 2)
	print(ans)


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


for i in range(int(input())):
	(a, b, c) = input().split()
	d = int(c) // 2
	b = int(b)
	f = min(b, d)
	ans = f + 2 * f
	b = b - f
	g = b // 2
	a = int(a)
	h = min(a, g)
	ans = ans + h + 2 * h
	print(ans)


n = int(input())
for _ in range(n):
	cont = 0
	stones = input().split(' ')
	a = int(stones[0])
	b = int(stones[1])
	c = int(stones[2])
	aux = min(b, int(c / 2))
	cont += aux + aux * 2
	b -= aux
	aux = min(a, int(b / 2))
	cont += aux + aux * 2
	print(cont)


n = int(input())
for i in range(n):
	cnt = 0
	(a, b, c) = [int(x) for x in input().split(' ')]
	f = min(b, c // 2)
	cnt += f + f * 2
	b -= f
	c -= f * 2
	d = min(a, b // 2)
	cnt += d + d * 2
	a -= d
	b -= d * 2
	print(cnt)


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


t = int(input())

def ans(a, b, c):
	tot = a + b + c
	while b > 0 and c > 1:
		b -= 1
		c -= 2
	while b > 1 and a > 0:
		b -= 2
		a -= 1
	return tot - a - b - c
l = []
for i in range(t):
	(a, b, c) = map(int, input().split(' '))
	l.append(ans(a, b, c))
print('\n'.join((str(k) for k in l)))


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

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

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

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

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def solve():
	(a, b, c) = num_input()
	if b == 0:
		print(0)
	elif b == 1 and c == 1:
		print(0)
	else:
		ans = 0
		i = b
		while i > 0:
			if 2 * i <= c:
				ans += 2 * i + i
				b -= i
				break
			i -= 1
		i = a
		while i > 0:
			if 2 * i <= b:
				ans += 2 * i + i
				break
			i -= 1
		temp = 0
		i = a
		while i > 0:
			if 2 * i <= b:
				temp += 2 * i + i
				b -= 2 * i
				break
			i -= 1
		i = b
		while i > 0:
			if 2 * i <= c:
				temp += 2 * i + i
				break
			i -= 1
		print(max(temp, ans))
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for k in range(t):
	s = 0
	(a, b, c) = [int(i) for i in input().split()]
	k = min(b, c // 2)
	s += 3 * k
	b -= k
	c -= 2 * k
	k = min(a, b // 2)
	s += 3 * k
	print(s)


n = int(input())
while n:
	n -= 1
	(a, b, c) = input().split()
	(a, b, c) = (int(a), int(b), int(c))
	stones = 0
	while b >= 1 and c >= 2:
		b -= 1
		c -= 2
		stones += 3
	while b >= 2 and a >= 1:
		a -= 1
		b -= 2
		stones += 3
	print(stones)


t = int(input())

def min(a, b):
	if a < b:
		return a
	else:
		return b
for i in range(t):
	times = 0
	(a, b, c) = input().split(' ')
	a = int(a)
	b = int(b)
	c = int(c)
	times = min(b, int(c / 2))
	b = b - times
	if b > 0:
		times = times + min(a, int(b / 2))
	print(times * 3)


t = int(input())
for t_ in range(t):
	(a, b, c) = [int(inp) for inp in input().split()]
	first = min(c // 2, b)
	print(3 * (first + min((b - first) // 2, a)))


t = int(input())
while t:
	t = t - 1
	ar = list(map(int, input().split()))
	a = ar[0]
	b = ar[1]
	c = ar[2]
	s = 0
	while b >= 1 and c >= 2:
		s = s + 3
		b = b - 1
		c = c - 2
	while a >= 1 and b >= 2:
		s = s + 3
		a = a - 1
		b = b - 2
	print(s)


querries = int(input())
for querrie in range(querries):
	abc = input().split()
	total = 0
	a = int(abc[0])
	b = int(abc[1])
	c = int(abc[2])
	while c > 1 and b > 0:
		total = total + 3
		c = c - 2
		b = b - 1
	while a > 0 and b > 1:
		total = total + 3
		b = b - 2
		a = a - 1
	print(total)


lst = []
while True:
	try:
		lst.append(input().split())
	except:
		break
for i in range(1, len(lst)):
	lst1 = list(map(int, lst[i]))
	sum = 0
	while True:
		if lst1[1] >= 1 and lst1[2] >= 2:
			sum += 3
			lst1[1] -= 1
			lst1[2] -= 2
		elif lst1[0] >= 1 and lst1[1] >= 2:
			sum += 3
			lst1[0] -= 1
			lst1[1] -= 2
		else:
			break
	print(sum)


def STONE(a, b, c):
	x = min(b, c // 2)
	b -= x
	stone = 3 * x
	t = min(a, b // 2)
	stone += 3 * t
	print(stone)
t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	STONE(a, b, c)
	t -= 1


t = int(input())
while t > 0:
	(a, b, c) = map(int, input().split())
	sumF = 0
	if b == 0:
		print(sumF)
	else:
		tempC = c // 2
		if tempC >= b:
			print(b * 2 + b)
		else:
			b = b - tempC
			sumF = tempC * 2 + tempC
			if a == 0:
				print(sumF)
			else:
				tempB = b // 2
				if tempB >= a:
					print(sumF + a * 2 + a)
				else:
					sumF = sumF + tempB * 2 + tempB
					print(sumF)
	t = t - 1


rr = lambda : input().strip()
rri = lambda : int(rr())
rrm = lambda : [int(x) for x in rr().split()]

def sol(a, b, c):
	res = 0
	if c // 2 < b:
		res += 3 * (c // 2)
		b -= c // 2
	else:
		return 3 * b
	if b // 2 < a:
		res += 3 * (b // 2)
		return res
	else:
		res += 3 * a
		return res
t = rri()
for _ in range(t):
	(a, b, c) = rrm()
	ans = sol(a, b, c)
	print(ans)


import os
import sys
from io import BytesIO, IOBase

def solution(a, b, c):
	(res1, res2) = (0, 0)
	(aa, bb, cc) = (a, b, c)
	while bb - 2 >= 0 and aa - 1 >= 0:
		bb -= 2
		aa -= 1
		res1 += 3
	while cc - 2 >= 0 and bb - 1 >= 0:
		cc -= 2
		bb -= 1
		res1 += 3
	(aa, bb, cc) = (a, b, c)
	while cc - 2 >= 0 and bb - 1 >= 0:
		cc -= 2
		bb -= 1
		res2 += 3
	while bb - 2 >= 0 and aa - 1 >= 0:
		bb -= 2
		aa -= 1
		res2 += 3
	write(max(res1, res2))

def main():
	for _ in range(r_int()):
		(a, b, c) = r_array()
		solution(a, b, c)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())

def w_array(arr):
	for x in arr:
		write(x, end=' ')
	write()
main()


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	y = 1
	count = 0
	while y != 0:
		if b >= 1 and c >= 2:
			c -= 2
			b -= 1
			count += 1
		elif a >= 1 and b >= 2:
			a -= 1
			b -= 2
			count += 1
		else:
			y = 0
	print(count * 3)


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


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	ans = 0
	if c >= b * 2:
		ans = 3 * b
		print(ans)
	elif c < b * 2:
		b = b - c // 2
		ans = c // 2 * 3
		if b >= a * 2:
			ans += 3 * a
			print(ans)
		elif b < a * 2:
			ans += b // 2 * 3
			print(ans)


for u in range(int(input())):
	(a, b, c) = [int(i) for i in input().split()]
	d = min(c // 2, b)
	print((d + min((b - d) // 2, a)) * 3)


for q in range(int(input())):
	(a, b, c) = [int(i) for i in input().split()]
	x = a
	y = c // 2
	while 2 * x + y > b and x > 0:
		x -= 1
	while 2 * x + y > b and y > 0:
		y -= 1
	print(3 * (x + y))


import math

def string_list(s, char):
	output_list = []
	intermediator = ''
	for i in range(len(s)):
		if s[i] != char:
			intermediator += s[i]
			if i == len(s) - 1:
				output_list.append(int(intermediator))
		elif intermediator:
			output_list.append(int(intermediator))
			intermediator = ''
	return output_list

def list_string(l, char):
	output_str = ''
	for i in range(len(l) - 1):
		output_str += str(l[i]) + char
	output_str += str(l[len(l) - 1])
	return output_str

def merge_sort(l):

	def merge(l1, l2):
		(i, j) = (0, 0)
		output_list = []
		while i < len(l1) and j < len(l2):
			if l1[i][0] < l2[j][0]:
				output_list.append(l1[i])
				i += 1
			else:
				output_list.append(l2[j])
				j += 1
		if i == len(l1):
			output_list += l2[j:]
		else:
			output_list += l1[i:]
		return output_list

	def sorts(l):
		if len(l) < 2:
			return l
		else:
			mid = len(l) // 2
			left = sorts(l[:mid])
			right = sorts(l[mid:])
			return merge(left, right)
	return sorts(l)

def make_it_even(n):
	if n < 2:
		return 0
	elif not n % 2:
		return n
	else:
		return n - 1

def main_function():
	output_list = []
	t = int(input())
	for i in range(t):
		count = 0
		(a, b, c) = string_list(input(), ' ')
		if 2 * b <= c:
			count += 3 * b
		else:
			count += c // 2 * 3
			b -= c // 2
			if 2 * a <= b:
				count += 3 * a
			else:
				count += 3 * (b // 2)
		output_list.append(count)
	return list_string(output_list, '\n')
print(main_function())


n = int(input())
for i in range(n):
	item = list(map(int, input().split()))
	second = min(item[2] // 2, item[1])
	first = min(item[0], (item[1] - second) // 2)
	print((first + second) * 3)


def solve(i, a, b, c):
	ans = 0
	while True:
		if b == 0 or (b == 1 and c < 2) or (a == 0 and c < 2):
			break
		if a > 0 and b >= c and (b >= 2):
			ans += 3
			a -= 1
			b -= 2
		elif b > 0 and c >= 2:
			ans += 3
			b -= 1
			c -= 2
	return ans
t = int(input())
for i in range(t):
	arr = [int(x) for x in input().split()]
	(a, b, c) = (arr[0], arr[1], arr[2])
	print(solve(i, a, b, c))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	cnt1 = 0
	t1 = a
	t2 = b
	t3 = c
	while b > 1 and a > 0:
		a = a - 1
		b = b - 2
		cnt1 = cnt1 + 3
	while b > 0 and c > 1:
		b = b - 1
		c = c - 2
		cnt1 = cnt1 + 3
	a = t1
	b = t2
	c = t3
	cnt2 = 0
	while b > 0 and c > 1:
		b = b - 1
		c = c - 2
		cnt2 = cnt2 + 3
	while b > 1 and a > 0:
		a = a - 1
		b = b - 2
		cnt2 = cnt2 + 3
	print(max(cnt1, cnt2))


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	ans = []
	for _ in range(n):
		(a, b, c) = LI()
		c1 = min(b, c // 2)
		b -= c1
		c2 = min(a, b // 2)
		ans.append(3 * c1 + 3 * c2)
	for x in ans:
		print(x)
main()


def solve():
	for _ in range(int(input())):
		(a, b, c) = map(int, input().split())
		total = 0
		_b = max(0, b - c // 2) if c else b
		total += 3 * (b - _b)
		_a = max(0, a - _b // 2) if _b else a
		total += 3 * (a - _a)
		print(total)
solve()


t = int(input())
l3 = []
for i in range(t):
	c = 0
	a = 0
	b = 0
	l1 = [int(num) for num in input().split()]
	if l1[2] >= 2 * l1[1]:
		l3.append(3 * l1[1])
	else:
		c = l1[2]
		a = int(c / 2)
		if l1[0] >= int((l1[1] - a) / 2):
			b = int((l1[1] - a) / 2) + 2 * int((l1[1] - a) / 2)
			l3.append(3 * a + b)
		else:
			l3.append(3 * a + 3 * l1[0])
	l1 = []
for i in range(t):
	print(l3[i])


import sys
from heapq import heappop
from heapq import heappush
from heapq import heapify
from bisect import insort
from bisect import bisect_right
from bisect import bisect_left
from sys import stdin, stdout
from collections import defaultdict
inp = lambda : int(stdin.readline())
sip = lambda : input()
mulip = lambda : map(int, input().split())
lst = lambda : list(map(int, stdin.readline().split()))
slst = lambda : list(sip())
arr2d = lambda x: [[int(j) for j in input().split()] for i in range(x)]
odds = lambda l: len(list(filter(lambda x: x % 2 != 0, l)))
evens = lambda l: len(list(filter(lambda x: x % 2 == 0, l)))
mod = pow(10, 9) + 7
for _ in range(inp()):
	(a, b, c) = mulip()
	m1 = min(b // 2, a) * 3 + min(b - 2 * min(b // 2, a), c // 2) * 3
	m2 = min(c // 2, b) * 3 + min((b - min(c // 2, b)) // 2, a) * 3
	print(max(m1, m2))


t = int(input())
for ti in range(t):
	sto = 0
	(a, b, c) = (int(i) for i in input().split(' '))
	if b > c // 2:
		if c // 2 == 0:
			if b < 2:
				print(0)
			else:
				bb = b - c // 2
				sto += c // 2 * 3
				sto += min(a, bb // 2) * 3
				print(sto)
		else:
			bb = b - c // 2
			sto += c // 2 * 3
			sto += min(a, bb // 2) * 3
			print(sto)
	else:
		print(b * 3)


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	cnt = 0
	while b > 0:
		if b > 0 and c >= 2:
			c = c - 2
			b = b - 1
			cnt = cnt + 3
			continue
		if b >= 2 and a > 0:
			b = b - 2
			a = a - 1
			cnt = cnt + 3
			continue
		if a == 0:
			break
		if c <= 1:
			break
	print(cnt)


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().strip().split(' '))
	s = 0
	if b >= c // 2:
		d = 3 * (c // 2)
		s += d
		b -= d // 3
	else:
		s += b * 3
		b = 0
	if a >= b // 2:
		e = 3 * (b // 2)
		s += e
	else:
		s += a * 3
	print(s)


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


for i in range(int(input(''))):
	(a, b, c) = input('').split()
	a = int(a)
	b = int(b)
	c = int(c)
	count = 0
	while 1:
		if b >= 1 and c >= 2:
			b = b - 1
			c = c - 2
			count = count + 3
		else:
			break
	while 1:
		if a >= 1 and b >= 2:
			a = a - 1
			b = b - 2
			count = count + 3
		else:
			break
	print(count)


for _ in range(int(input())):
	(A, B, C) = map(int, input().split())
	val = C // 2
	tot = 0
	if B > val:
		tot += val
		tot += val * 2
		B -= val
	else:
		tot += B
		tot += B * 2
		B = 0
	var = B // 2
	if A > var:
		tot += var
		tot += var * 2
		A -= var
	else:
		tot += A
		tot += A * 2
		A = 0
	print(tot)


n_lines = int(input())
res_arr = []
for i in range(n_lines):
	nums = [int(i) for i in input().split()]
	times1 = min(nums[1], nums[2] // 2)
	remaining1 = nums[1] - times1
	times2 = min(nums[0], remaining1 // 2)
	res = (times1 + times2) * 3
	res_arr.append(res)
for res in res_arr:
	print(res)


t = int(input())
out = []
for i in range(t):
	(a, b, c) = map(int, input().split())
	count = 0
	while b >= 1 and c >= 2:
		b -= 1
		c -= 2
		count += 3
	while a >= 1 and b >= 2:
		a -= 1
		b -= 2
		count += 3
	out.append(str(count))
print('\n'.join(out))


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


t = int(input())

def second(a, b, c):
	ans = 0
	while b >= 2 and a > 0:
		ans += 3
		b -= 2
		a -= 1
	while c >= 2 and b > 0:
		ans += 3
		c -= 2
		b -= 1
	return ans

def first(a, b, c):
	ans = 0
	while c >= 2 and b > 0:
		ans += 3
		c -= 2
		b -= 1
	while b >= 2 and a > 0:
		ans += 3
		b -= 2
		a -= 1
	return ans
for w in range(t):
	(a, b, c) = [int(i) for i in input().split()]
	print(max(first(a, b, c), second(a, b, c)))


from math import ceil
n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	total = min(b, c // 2)
	rep = 3 * total + 3 * min(a, (b - total) // 2)
	print(rep)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	delta = [int(x) for x in input().split()]
	a = delta[0]
	b = delta[1]
	c = delta[2]
	one = 0
	two = 0
	t1 = int(c // 2)
	t2 = b
	two = min(t1, t2)
	b -= two
	c -= 2 * two
	t3 = int(b // 2)
	t4 = a
	one = min(t3, t4)
	print(3 * (one + two))


for i in range(int(input())):
	q = 0
	(x, y, z) = [int(i) for i in input().split()]
	if z >= 2:
		if z // 2 >= y:
			q += 3 * y
			y = 0
			z = 0
		else:
			q += 3 * (z // 2)
			y -= z // 2
			z = 0
	if y >= 2 and x >= 1:
		if y // 2 >= x:
			q += 3 * x
		else:
			q += 3 * (y // 2)
	print(q)


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


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


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	r = c // 2
	total = 0
	if r >= b:
		total = total + b + b * 2
		b = 0
	elif r < b:
		total = total + r + r * 2
		b = b - r
	t = b // 2
	total = total + 2 * min(a, t) + min(a, t)
	print(total)


def ii():
	a = int(input())
	return a

def ai():
	a = list(map(int, input().split()))
	return a

def mi():
	a = map(int, input().split())
	return a
for _ in range(ii()):
	(a, b, c) = mi()
	ans = 0
	if b >= c // 2:
		ans += c // 2 + c // 2 * 2
		b -= c // 2
	elif b < c // 2:
		ans += b + b * 2
		print(ans)
		continue
	if a >= b // 2 and b != 0:
		ans += b // 2 + b // 2 * 2
	elif a < b // 2:
		ans += a + a * 2
	print(ans)


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict

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

def main():
	t = int(input())
	for i in range(t):
		(a, b, c) = getlist()
		ans = 0
		if b * 2 <= c:
			ans += 3 * b
			b = 0
		else:
			x = c // 2
			ans += 3 * x
			b -= x
		if a * 2 <= b:
			ans += 3 * a
		else:
			y = b // 2
			ans += 3 * y
		print(ans)
main()


n = int(input())
for i in range(n):
	(ai, bi, ci) = map(int, input().split())
	if 2 * bi <= ci:
		print(3 * bi)
	elif bi == 0:
		print('0')
	else:
		y = bi - int(ci / 2)
		if 2 * ai <= y:
			print(3 * (ai + int(ci / 2)))
		else:
			print(3 * (int(ci / 2) + int(y / 2)))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	c1 = c
	a1 = a
	b1 = b
	ans1 = 0
	ans = 0
	if c >= 2 and b >= 1:
		mn2 = min(2 * b, c)
		b = b - mn2 // 2
		c = c - mn2 // 2 * 2
		ans += 3 * (mn2 // 2)
	if b >= 2 and a >= 1:
		mn1 = min(2 * a, b)
		a = a - mn1 // 2
		b = b - mn1 // 2 * 2
		ans += 3 * (mn1 // 2)
	if b1 >= 2 and a1 >= 1:
		mn4 = min(2 * a1, b1)
		a1 = a1 - mn4 // 2
		b = b - mn4 // 2 * 2
		ans1 += 3 * (mn4 // 2)
	if c1 >= 2 and b1 >= 1:
		mn3 = min(2 * b, c)
		c1 = c1 - mn3 // 2 * 2
		b1 = b1 - mn3 // 2
		ans1 += 3 * (mn3 // 2)
	print(max(ans1, ans))


TestCase = input()
if TestCase.isdigit():
	TestCase = int(TestCase)
while TestCase > 0:
	listi = list(map(int, input().split()))
	count = 0
	while listi[2] > 1 and listi[1] > 0:
		count += 1 + 2
		listi[2] -= 2
		listi[1] -= 1
	while listi[1] > 1 and listi[0] > 0:
		count += 1 + 2
		listi[1] -= 2
		listi[0] -= 1
	print(count)
	TestCase -= 1


def countStones(a, b, c, cache):
	if (a, b, c) in cache:
		return cache[a, b, c]
	(left, right) = (0, 0)
	if a >= 1 and b >= 2:
		left = 3 + countStones(a - 1, b - 2, c, cache)
	if b >= 1 and c >= 2:
		right = 3 + countStones(a, b - 1, c - 2, cache)
	cache[a, b, c] = max(left, right)
	return cache[a, b, c]
t = int(input())
for _ in range(t):
	(a, b, c) = map(int, input().split())
	cache = {}
	print(countStones(a, b, c, cache))


for t in range(int(input())):
	l = list(map(int, input().split()))
	c = 0
	if l[1] == 0:
		print(0)
	else:
		while l[1] > 0 and l[2] >= 2:
			l[2] = l[2] - 2
			l[1] = l[1] - 1
			c += 3
		while l[1] >= 2 and l[0] > 0:
			l[1] = l[1] - 2
			l[0] = l[0] - 1
			c += 3
		print(c)


t = int(input())
while t > 0:
	ans = 0
	(a, b, c) = map(int, input().split())
	if c % 2 == 0:
		f = min(c, 2 * b)
		ans += f
		b -= f // 2
	elif c % 2 == 1:
		f = min(c - 1, 2 * b)
		ans += f
		b -= f // 2
	if b % 2 == 0:
		f = min(b, 2 * a)
		ans += f
	elif b % 2 == 1:
		f = min(b - 1, 2 * a)
		ans += f
	ans = int(ans * 1.5)
	print(ans)
	t -= 1


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


t = int(input())
a = []
b = []
c = []
for i in range(t):
	values = input().split()
	abc = [int(x) for x in values]
	a.append(abc[0])
	b.append(abc[1])
	c.append(abc[2])

def stones(a, b, c):
	stones = 0
	if a < 1 and c < 2:
		return stones
	while b >= 1:
		if a <= 1 and c < 2 and (b < 2):
			return stones
		elif a == 0 and c < 2:
			return stones
		elif b == 1 and c < 2:
			return stones
		elif c >= 2 and b >= 1:
			c -= 2
			b -= 1
			stones += 3
		elif b >= 2 and a >= 1:
			b -= 2
			a -= 1
			stones += 3
	return stones
for i in range(t):
	print(stones(a[i], b[i], c[i]))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	sum = 0
	while True:
		count = 0
		if c >= 2 and b > 0:
			x = min(c // 2, b)
			sum += 3 * x
			c = c - 2 * x
			b = b - x
			count = 1
		elif b >= 2 and a > 0:
			y = min(b // 2, a)
			sum += 3 * y
			b = b - 2 * y
			a = a - y
			count = 1
		elif count == 0:
			break
	print(sum)


t = int(input())
for i in range(t):
	(a, b, c) = list(map(int, input().split()))
	sum1 = 0
	if b > 0:
		y = c // 2
		if y <= b:
			sum1 += c // 2 * 2 + y
			b -= y
			g = b // 2
			if g <= a:
				sum1 += b // 2 * 2 + g
			else:
				sum1 += a + a * 2
		else:
			sum1 += b + b * 2
			c -= b * 2
			b = 0
	print(sum1)