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