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)