from sys import stdin,stdout
I = lambda : map(int,stdin.readline().split())

t = input()
for _ in range(t):
	a,b,c = I()
	ans = 0
	tt = min(b, c/2);
	b -= tt;
	ans += tt*3;
	ans += min(a, b/2)*3;
	print ans