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