'''input
3
3 4 5
1 0 5
5 3 2

'''
 
from bisect import bisect_right as bl
from random import randint as R
RI = lambda : [int(_x) for _x in raw_input().split()]
 
mod = 10**9 + 7
 
for _ in range(input()):
	a,b,c = RI()

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